@treenity/sequelizer
v1.0.6
Published
Convert foreign schemas into Sequelize model definitions
Downloads
832
Readme
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. |