Sequelize: Where is an example of using bulkDelete with criteria?
down: (queryInterface, Sequelize) => {
const Op = Sequelize.Op;
return queryInterface.bulkDelete(
'Foo',
{[Op.or]: [{name: x}, {name: y}]}
);
}
1st arg is the table name, 2nd arg is the where
value that indicates which rows to delete.
I tried using @Michael McCabe's suggestion and kept getting ERROR: Invalid value [object Object]
. Once I got rid of where
from the second argument (the identifier argument), I was able to get it working:
down: (queryInterface, Sequelize) => {
const Op = Sequelize.Op
return queryInterface.bulkDelete('users', {id: {[Op.in]: [2, 3]}}, {})
}