Sequelize.js delete query?

lakenen picture lakenen · Dec 6, 2011 · Viewed 137.9k times · Source

Is there a way to write a delete/deleteAll query like findAll?

For example I want to do something like this (assuming MyModel is a Sequelize model...):

MyModel.deleteAll({ where: ['some_field != ?', something] })
    .on('success', function() { /* ... */ });

Answer

ncksllvn picture ncksllvn · Nov 11, 2015

For anyone using Sequelize version 3 and above, use:

Model.destroy({
    where: {
        // criteria
    }
})

Sequelize Documentation - Sequelize Tutorial