No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ben Carless 22225dfa8e added winston and verbose debugging 1 year ago
.gitignore initial v0.0.0 1 year ago
index.js added winston and verbose debugging 1 year ago
package-lock.json added winston and verbose debugging 1 year ago
package.json added winston and verbose debugging 1 year ago
readme.md added ability to omit columns 1 year ago
test.js default to TEXT for STRING 1 year ago

readme.md

Create a sequelize model from a JSON object using JSON Schema

sequelize package

to-json-schema package

Git Repo

This has been written quickly with little testing to fulfill and immediate need - contributions are appreciated.

const sqlGenerator = require('json-to-sequelize-model')

var data = JSON.parse(fs.readFileSync('object.json', 'utf-8'))

var data = {

}

// JSON to Sequelize Options
var options = {
    modelOptions: {
        primaryKey: "ID",
        omitColumns: ["_RowNumber", "Person Responsible", "Progress", "Date", "Week Label"]
    },
    schemaOptions: {
        arrays: {
            mode: 'first'
        }
    }
}

sqlGenerator.jsonToModel(data, options).then((model) => {
    console.log("Created model from JSON data.")
    const Appointments = sqlBeyond.sequelize.define("123_Appt", model)
    Appointments.sync()
})

I’ll tidy this up one day…