@treenity/sequelizer

1.0.6 • Public • Published

Sequelizer

Transform foreign schema definitions to Sequelize model definitions

Kind: global class

Sequelizer.fromJsonSchema(schemas, schemaId, options) ⇒ Object

Convert a JSON schema into a Sequelize model definition

See example/fromJsonSchema.js for example usage.

Kind: static method of Sequelizer
Returns: Object - The model definition to use with sequelize.define().

Param Type Description
schemas Object | Array A list of json schemas or a single Json schema object.
schemaId string | null The schema id to build the model definition from.
options
options.uniqueFields Array a list of fields that have the UNIQUE constraint
options.notNullFields Array a list of fields that have the NOT NULL constraint
options.mixinFields Array a list of properties that are sub-schemas (object or $ref types) to "flatten" into the model definition. For example, the schema property "address": { "$ref": "http://example.com/schemas/address" } will create "address" prefixed fields from the address sub-schema, resulting in model fields like "addressStreetName", "addressStreetNumber", etc.
options.customFieldDefinitions object Override the generated field definitions with your own. Field name to field definition mapping.

Package Sidebar

Install

npm i @treenity/sequelizer

Weekly Downloads

144

Version

1.0.6

License

MIT

Unpacked Size

16.9 kB

Total Files

11

Last publish

Collaborators

  • timelyapp-usr
  • krizka
  • kkriz