1.1.4 • Published 4 years ago

sequelizer v1.1.4

Weekly downloads
168
License
MIT
Repository
github
Last release
4 years ago

Sequelizer

Build Status

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

ParamTypeDescription
schemasObject | ArrayA list of json schemas or a single Json schema object.
schemaIdstring | nullThe schema id to build the model definition from.
options
options.uniqueFieldsArraya list of fields that have the UNIQUE constraint
options.notNullFieldsArraya list of fields that have the NOT NULL constraint
options.mixinFieldsArraya 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.customFieldDefinitionsobjectOverride the generated field definitions with your own. Field name to field definition mapping.