API Reference Source

Upgrade to v6

Sequelize v6 is the next major release after v5. Below is a list of breaking changes to help you upgrade.

Breaking Changes

Support for Node 10 and up

Sequelize v6 will only support Node 10 and up #10821.

CLS

You should now use cls-hooked package for CLS support.

  const cls = require('cls-hooked');
  const namespace = cls.createNamespace('....');
  const Sequelize = require('sequelize');

  Sequelize.useCLS(namespace);

Bluebird now supports async_hooks. This configuration will automatically be enabled when invoking Sequelize.useCLS. This way, using cls-bluebird is no longer necessary.

Model

options.returning

Option returning: true will no longer return attributes that are not defined in the model. Old behavior can be achieved by using returning: ['*'] instead.

Model.changed()

This method now tests for equality with _.isEqual and is now deep aware for JSON objects. Modifying a nested value for a JSON object won't mark it as changed (since it is still the same object).

  const instance = await MyModel.findOne();

  instance.myJsonField.someProperty = 12345; // Changed from something else to 12345
  console.log(instance.changed()); // false

  await instance.save(); // this will not save anything

  instance.changed('myJsonField', true);
  console.log(instance.changed()); // ['myJsonField']

  await instance.save(); // will save

Changelog

6.0.0-beta.5

6.0.0-beta.4

6.0.0-beta.3

6.0.0-beta.2