Sequelize is compatible to the following versions of Node.JS:
Sincev1.3.0
there are multiple ways of adding listeners to asynchronous requests. First of all, each time you call a finder method or save an object, sequelize triggers asynchronous logic. To react to the success or the failure (or both) of the request, you can do the following:
// the old, pre-v1.3.0 way
Model.findAll().on('success', function(models) { /* foo */ })
Model.findAll().on('failure', function(err) { /* bar */ })
// the new, >=v1.3.0 way
// each one is valid
Model.findAll().on('success', function(models) { /* foo */ })
Model.findAll().success(function(models) { /* foo */ })
Model.findAll().ok(function(models) { /* foo */ })
// Model.findAll().on('failure', function(err) { /* bar */ }) ==> invalid since v1.5.0
Model.findAll().on('error', function(err) { /* bar */ }) // ==> new since v1.5.0
Model.findAll().error(function(err) { /* bar */ })
Model.findAll().failure(function(err) { /* bar */ })
Model.findAll().fail(function(err) { /* bar */ })
Model.findAll().complete(function(err, result) { /* bar */ })
Model.findAll().done(function(err, result) { /* bar */ })
// As of 1.7.0 we support Promises/A
var self = User
user.find(1).then(function(user1) {
return user1.increment(['aNumber'], 2)
}).then(function(user2) {
return user.find(1)
}).then(function(user3) {
console.log(user3.aNumber) // 2
}, function(err) {
// err...
})
// For functions with multiple success values (e.g. findOrCreate) there is also spread
user.findOrCreate(...).spread(function(user, wasCreated) {
// all arguments are passed
})
user.findOrCreate(...).then(function(user) {
// only the first argument is passed
})
Please notice:Since v1.5.0 the 'error' event is used to notify about errors. If such events aren't caught however, Node.JS will throw an error. So you would probably like to catch them :D
If you want to keep track about latest development of sequelize or to just discuss things with other sequelize users you might want to take a look at the following resources:
Here is a list of companies and projects that are using Sequelize in real world applications:
Shutterstock Images LLC is a leading global provider of high-quality stock footage, stock photography, vectors and illustrations to creative industry professionals around the world. Shutterstock works closely with its growing contributor community of artists, photographers, videographers and illustrators to curate a global marketplace for royalty-free, top-quality imagery. Shutterstock adds tens of thousands of rights-cleared images and footage clips each week, with more than 18 million files currently available.
Clevertech builds web and mobile applications for startups using Lean and Agile methodologies. Clevertech relies on Sequelize for its applications, its speed, versatility and data flexibility. Clevertech contributes back to open source development and its expert developers support the continuing effort to make sequelize the best ORM for Node projects.
Metamarkets enables buyers and sellers of digital media to visualize insights and make decisions with real-time pricing, performance, and audience data.
On Innofluence, people meet and engage in challenges, questions, and dilemmas – big and small – to be inspired, to explore, and to find better solutions and answers. Together. Ask the network a question, and they will in return reply with Input, exciting points of view, and new reflections. Or help and inspire others in need of your input.
If you want to get listed here, just drop me a line or send me a pull-request on Github!