# sequelizer

> Convert foreign schemas into Sequelize model definitions

Latest version **1.1.4** (published 2020-02-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install sequelizer
pnpm add sequelizer
yarn add sequelizer
bun add sequelizer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2020-02-19 |
| First published | 2016-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 16.6 KB |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Ronald Ng |
| Maintainers | ronalddddd |
| Keywords | sequelize, json, schema, translate, convert |

## Links

- npm: https://www.npmjs.com/package/sequelizer
- Repository: https://github.com/ronalddddd/sequelizer
- Homepage: https://github.com/ronalddddd/modelize#readme
- Issues: https://github.com/ronalddddd/modelize/issues
- npm.io page: https://npm.io/package/sequelizer

## Dependencies (1)

- [sequelize](https://npm.io/package/sequelize.md) ^5.21.4

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.1.4 (latest) — 2020-02-19
- 1.1.3 — 2016-03-09
- 1.1.1 — 2016-03-08
- 1.1.0 — 2016-03-03
- 1.0.2 — 2016-02-28
- 1.0.1 — 2016-02-28
- 1.0.0 — 2016-02-27

## README

<a name="Sequelizer"></a>
## Sequelizer
[![Build Status](https://travis-ci.org/ronalddddd/sequelizer.svg?branch=master)](https://travis-ci.org/ronalddddd/sequelizer)

Transform foreign schema definitions to Sequelize model definitions

**Kind**: global class  
<a name="Sequelizer.fromJsonSchema"></a>
### Sequelizer.fromJsonSchema(schemas, schemaId, options) ⇒ <code>Object</code>
Convert a JSON schema into a Sequelize [model definition](http://docs.sequelizejs.com/en/latest/docs/models-definition/#definition)

See [example/fromJsonSchema.js](example/fromJsonSchema.js) for example usage.

**Kind**: static method of <code>[Sequelizer](#Sequelizer)</code>  
**Returns**: <code>Object</code> - The model definition to use with `sequelize.define()`.  

| Param | Type | Description |
| --- | --- | --- |
| schemas | <code>Object</code> &#124; <code>Array</code> | A list of json schemas or a single Json schema object. |
| schemaId | <code>string</code> &#124; <code>null</code> | The schema id to build the model definition from. |
| options |  |  |
| options.uniqueFields | <code>Array</code> | a list of fields that have the UNIQUE constraint |
| options.notNullFields | <code>Array</code> | a list of fields that have the NOT NULL constraint |
| options.mixinFields | <code>Array</code> | 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 | <code>object</code> | Override the generated field definitions with your own. Field name to field definition mapping. |

---
_Source: https://npm.io/package/sequelizer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
