The documentation doesn\'t explain the difference between sequelize.define and Model.init. All it says is Internally, sequelize.define calls Model.init
What
I was recently wondering the same thing when I came across this question. I did some further investigation and found some additional details explained in the documentation that may be useful here.
TL:DR
Overall, the differences are strictly related to syntax, and using sequelize.define
or Model.init
comes down to personal preference. I do not believe one is preferred over the other, especially since the Sequelize CLI tool generates model definitions using the sequelize.define
method, and it is not explicitly stated anywhere.
Models can be defined in two equivalent ways in Sequelize:
Calling sequelize.define(modelName, attributes, options) API documentation on define
Extending Model and calling init(attributes, options) API documentation on init
After a model is defined, it is available within sequelize.models by its model name.
As you mentioned and as stated in the documentation:
Internally, sequelize.define calls Model.init, so both approaches are essentially equivalent.