Don't want mentioned each and every fields in schema of sequelize

12 views
Skip to first unread message

Sumitra Roy

unread,
Dec 20, 2017, 9:27:47 AM12/20/17
to Sequelize

Please Help::

                      When ever I create schema in Sequelize always have to mentioned all fields of database in it. The problem is that in case there is a table consisting above 90 fields. It is very much difficult for me to write down all fields name with their datatype. is there any other way so that I can over look this step and allow for all fields don't want to mentioned each and every fields every time. 

I used laravel Eloquent ORM there are two options are there. Fillable for write each fields manually. For Guarded not to mentioned an fields name in model.

I want something similar like that for Sequelize.


const Foo = sequelize.define('foo', {
 flag: { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: true },
 myDate: { type: Sequelize.DATE, defaultValue: Sequelize.NOW },
 title: { type: Sequelize.STRING, allowNull: false },
 uniqueOne: { type: Sequelize.STRING,  unique: 'compositeIndex' },
 uniqueTwo: { type: Sequelize.INTEGER, unique: 'compositeIndex' },
 someUnique: { type: Sequelize.STRING, unique: true },
 })

Thank in advanced.
Reply all
Reply to author
Forward
0 new messages