seanjs icon indicating copy to clipboard operation
seanjs copied to clipboard

Sequelizejs Breaking Changes

Open felipo opened this issue 8 years ago • 1 comments

Breaking Changes

Node version: To use new ES2015 features, we now require at least Node 4. From now on, we will support all current LTS versions of Node.
The counter cache plugin, and consequently the counterCache option for associations has been removed. The same behaviour can be achieved using afterCreate and afterDelete hooks.
Removed MariaDB dialect. This was just a thin wrapper around MySQL, so using dialect: 'mysql' instead should work with no further changes
Removed default REPEATABLE_READ transaction isolation. The isolation level now defaults to that of the database. Explicitly pass the required isolation level when initiating the transaction.
Removed support for pool: false. To use a single connection, set pool.max to 1.
(MySQL) BIGINT now gets converted to string when number is too big
Removed support for referencesKey, use a references object

references: {
    key: '',
    model: ''
}

classMethods and instanceMethods are removed.

Previous:

const Model = sequelize.define('Model', {
    ...
}, {
    classMethods: {
        associate: function (model) {...}
    },
    instanceMethods: {
        someMethod: function () { ...}
    }
});

New:

const Model = sequelize.define('Model', {
    ...
});

// Class Method
Model.associate = function (models) {
    ...associate the models
};

// Instance Method
Model.prototype.someMethod = function () {..}

Model.Instance and instance.Model are removed. To access the Model from an instance, simply use instance.constructor. The Instance class (Model.Instance) is now the Model itself.

Taken from: http://docs.sequelizejs.com/manual/tutorial/upgrade-to-v4.html

felipo avatar Jun 27 '17 15:06 felipo

This changes is mandatory if you wanna update Sequelize to V4, otherwise, update the packague.json file with a 3.x version.

felipo avatar Jun 27 '17 15:06 felipo