Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use bulkDestroy in Sequelize

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...

like image 735
Jonathan Solorzano Avatar asked Sep 10 '26 05:09

Jonathan Solorzano


1 Answers

You've missed the id from your criteria.

Model.destroy({ where: { id: [1,2,3,4] }})
like image 151
Adam Avatar answered Sep 13 '26 08:09

Adam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!