Reputation: 7032
I'd like to know how to delete all values in an array, my array contains the ids like: [1,2,3,4]
, I've tried:
models.products
.destroy({where: {req.body.ids}})
.then(function(data){ res.json(data) })
But I got data
undefined, and nothing is deleted...
Upvotes: 3
Views: 2745
Reputation: 646
Just to add to +Adam's response:
for arrays you'll need to add an $in: clause.
Models.products
.destroy({where: {$in: req.body.ids}})
...
Upvotes: 2
Reputation: 5253
You've missed the id
from your criteria.
Model.destroy({ where: { id: [1,2,3,4] }})
Upvotes: 8