Skip to content

v6.0.0@next

Compare
Choose a tag to compare
@sushantdhiman sushantdhiman released this 12 Jun 21:15
· 2521 commits to main since this release

6.0.0 (2019-06-12)

Bug Fixes

Build System

Code Refactoring

BREAKING CHANGES

  • hooks: In order to streamline API:
  • All method style add hook functions have been removed in favor of a composition based approach.
  • Hook names have been removed, you can add and remove them by function reference instead which was supported before.
  • Another notable change that this inside of hooks no longer refers to the the the hook subject, it should not be used.

This affects Model, Sequelize and Transaction.

Composition

Before: MyModel.beforeCreate(...)
After: MyModel.hooks.add('beforeCreate', ...)

Before: MyModel.addHook('beforeCreate', ...)
After: MyModel.hooks.add('beforeCreate', ...)

Before: MyModel.removeHook('beforeCreate', ...)
After: MyModel.hooks.remove('beforeCreate', ...)

Before: transaction.afterCommit(...)
After: transaction.hooks.add('afterCommit', ...)

Names

Before:

MyModel.addHook('beforeCreate', 'named', fn);
MyModel.removeHook('beforeCreate', 'named');

After:

MyModel.hooks.add('beforeCreate', fn);
MyModel.hooks.remove('beforeCreate', fn);

Scope

Before: MyModel.addHook('beforeCreate', function() { this.someMethod(); });
After: MyModel.hooks.add('beforeCreate', () => { MyModel.someMethod(); });

  • cls: All CLS support has been removed.

Migration guide:
If you do not use CLS, you can ignore this.
Check all your usage of the .transaction method and make you sure explicitly pass the transaction object for each subsequent query.

  • model: Model.build has been removed. Use Model.bulkBuild or new Model instead.

Co-authored-by: Simon Schick demwizzy@gmail.com

  • operators: If you have relied on accessing sequelize operators via Symbol.for('gt') etc. you must now prefix them with sequelize.operator eg.
    Symbol.for('sequelize.operator.gt')
  • querying: Operator aliases were soft deprecated via the opt-in option
    operatorAlises in v5 they have been entirely removed.

Please refer to previous changelogs for the migration guide.

  • Only NodeJS v8 and greater are now supported