Sequelize.js delete query?
For anyone using Sequelize version 3 and above, use:
Model.destroy({ where: { // criteria }})
I've searched deep into the code, step by step into the following files:
https://github.com/sdepold/sequelize/blob/master/test/Model/destroy.js
https://github.com/sdepold/sequelize/blob/master/lib/model.js#L140
https://github.com/sdepold/sequelize/blob/master/lib/query-interface.js#L207-217
https://github.com/sdepold/sequelize/blob/master/lib/connectors/mysql/query-generator.js
What I found:
There isn't a deleteAll method, there's a destroy() method you can call on a record, for example:
Project.find(123).on('success', function(project) { project.destroy().on('success', function(u) { if (u && u.deletedAt) { // successfully deleted the project } })})
Don't know if the question is still relevant but I have found the following on Sequelize's documentation.
User.destroy('`name` LIKE "J%"').success(function() { // We just deleted all rows that have a name starting with "J"})
http://sequelizejs.com/blog/state-of-v1-7-0
Hope it helps!