Sascha Depold

Engineering Manager


Changes in Sequelize 1.0.0

With Sequelize 1.0.0 the project was completly rewritten and had some major api changes, which will break your app, if you dont fix em. This post summarizes all changes and points out improvements and new features.


Disable logging of Sequelize is not longer realized via the options disableLogging:true, but with logging:false. So you now have to do this:

new Sequelize(config.database, config.username, config.password, {
logging: false


Sequelize.chainQueries was replaced by Sequelize.Utils.QueryChainer. The API for that is:

new Sequelize.Utils.QueryChainer
.on(success, function() { // done :) })


The instantiation of models has changed:

// Before
new Model({attr1: 1, attr2: 2}).save()

// to first create the instance and save it afterwards or…

// to create it and directly write it to the database


Sequelize changed from callback-driven to listener-driven architecture. So you now have to do

.on(success, function(model){})
.on(failure, function(err){})

instead of

new Model({a:1}).save(function(err, model) {})


Syncing sequelize is the same way then before, but got some convenience:

Sequelize.sync(function(){ })

Sequelize.sync({force: true}).on(‘success’, function(){ })

New stuff / Other changes

Added a count method to Model:

Model.count().on(success, function(num) {})

Added option passing everywhere:

Model.count({where: {attr1: 1}})
Model.find({where: {attr1: 1}})
Model.findAll({where: {attr1: 1}})
//Take a look at this for further information.

Added more options for Model definition: unique, primaryKey, autoIncrement. Take a look at this.

Some sequelize options have changed:

  • Don’t add timestamp attributes: timestamps: false
  • Don’t delete things from the database: paranoid: true
  • Use underscore names instead of camelcase: underscore: true
  • Don’t pluralize table names: freezeTableName: true

File import changed. The imported file should only return a single function. Take a look at the usage section on the Sequelize page.

The association API has changed. Please take a deeper look at this.

There might be more stuff, but I dunno them at the moment :D Have fun!

And btw. … expect more stuff in the future. I will write about sequelize in my master thesis :)