0.2.0 • Published 1 year ago
json-to-sequelize-model v0.2.0
Create a sequelize model from a JSON object using JSON Schema
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...