sequelize-auto
sequelize-auto copied to clipboard
Add option to create instance instead of automatically returning the definition of the model
Instead of defining the model like this:
module.exports = function(sequelize, DataTypes) {
return sequelize.define('User', {
// Model attributes are defined here
firstName: {
type: DataTypes.STRING,
allowNull: false
},
lastName: {
type: DataTypes.STRING
// allowNull defaults to true
},
}
}
Being able to choose to define it with an instance:
module.exports = function(sequelize, DataTypes) {
const User = sequelize.define('User', {
// Model attributes are defined here
firstName: {
type: DataTypes.STRING,
allowNull: false
},
lastName: {
type: DataTypes.STRING
// allowNull defaults to true
}
}, {
// Other model options go here
});
// Hook
User.beforeCreate(()=>{
// something
})
return User;
}
If that is possible to already do, where can I find that information?