0.2.0 • Published 1 year ago

json-to-sequelize-model v0.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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...

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago