I'm trying to write a seed file's down
and I'd like to bulkDelete
the data I created in my up
. But I can't find any documentation on how to do this. The official docs don't give an example: http://docs.sequelizejs.com/class/lib/query-interface.js~QueryInterface.html#instance-method-bulkDelete
Can someone show me how to bulkDelete
all rows in table Foo
where name
equals x
or name equals y
?
down: (queryInterface, Sequelize) => {
return queryInterface.bulkDelete('Foo', [what do I put here?], {});
}
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]}}, {})
}
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With