Sequelize generator
CLI tool to generate sequelize models based on simple JS config
Install
- inside your project
npm install --save-dev sequelizator
- globally
npm install -g sequelizator
Using
sequelizator <folder>
- Sequelize models will be created inside
<folder>
<folder>
must contains aconfig.js
file like thisexample/config.js
- You can create a script in your project's package.json to run this way:
npm run sequelizator
...
"scripts": {
...
"sequelizator": "sequelizator ./src/models/",
...
},
...
config.js
Example "table": "users" "model": "User" "columns": "name": "name" "type": "STRING" "allowNull": false "name": "email" "type": "STRING" "name": "password" "type": "STRING" "relations": "type": "1:n" "model": "Post" "table": "posts" "model": "Post" "columns": "name": "title" "type": "STRING" "name": "published" "type": "BOOLEAN" "defaultValue": true "allowNull": false "relations": "type": "n:n" "model": "Tag" "table": "tags" "model": "Tag" "columns": "name": "name" "type": "STRING" "name": "order" "type": "INTEGER" "defaultValue": 1 "allowNull": false "relations": "type": "n:n" "model": "Post"