When you start building web applications and APIs you often need something that interacts with databases for you. Maintaining relationships between tables, fetching related records and managing transactions gets very repetitive over time when using just raw queries. Sequelize abstracts these tasks away for you and provides you with a database layer.
It has been under development since July 2010 and is used by a large number of users. It’s under active development with new features introduced relatively often.
- Schema definition
- Schema synchronization/dropping
- 1:1, 1:M & N:M Associations
- Through models
- Hooks/callbacks/lifecycle events
- Prefetching/association including
- CLI (sequelize-cli)
Sequelize v5.1.0 has been released. The update change as follows:
Support for Node 6 and up
Sequelize v5 will only support Node 6 and up #9015
With v4 you started to get a deprecation warning
String based operators are now deprecated. Also concept of operators was introduced. These operators are Symbols which prevent hash injection attacks.
- Operators are now enabled by default.
- You can still use string operators by passing an operators map in
operatorsAliases, but that will give you deprecation warning.
- Op.$raw is removed
Sequelize now ship official typings #10287. You can consider migrating away from external typings which may get out of sync.
With v5 Sequelize now use
sequelize-poolwhich is a modernized fork of
email@example.com. You no longer need to call
sequelize.closeto shutdown pool, this helps with lambda executions. #8468
Custom validators defined per attribute (as opposed to the custom validators defined in the model’s options) now run when the attribute’s value is
true(while previously they didn’t run and the validation succeeded immediately). To avoid problems when upgrading, please check all your custom validators defined per attribute, where
true, and make sure all these validators behave correctly when the value is
null. See #9143.
Model.attributesnow removed, use
Note: Please don’t confuse this with
options.attributes, they are still valid
With v5 if
deletedAtis set, record will be considered as deleted.
paranoidoption will only use
deletedAtas flag. #8496
updateOnDuplicateoption which used to accept boolean and array, now only accepts non-empty array of attributes. #9288
Model.options.underscoredis changed. You can find full specifications here.
underscoredoptions are merged into single
- All attributes are now generated with camelcase naming by default. With the
underscoredoption set to
fieldoption for attributes will be set as underscored version of attribute name.
underscoredwill control all attributes including timestamps, version and foreign keys. It will not affect any attribute which already specifies the
Many model based aliases has been removed #9372