I have a multiple contentIds.
Mode.findAll({ where: { id: contentIds } })
After finding all how can I Delete multiple rows from a table.
Or tell me other options to delete multiple records with a single query.
To delete rows of data from your SQL table using Sequelize, you need to use the provided destroy() method. The destroy() method can be called from any Model or instance of your Model to delete rows from your table.
Adding multiple rows at once using Sequelize bulkCreate() method. When you need to insert multiple rows to your SQL database table, you can use the Sequelize bulkCreate() method. The bulkCreate() method allows you to insert multiple records to your database table with a single function call.
Who uses Sequelize? 87 companies reportedly use Sequelize in their tech stacks, including Barogo, kevin., and Goopy.
Example:
Model.destroy({ where: { id: [1,2,3,4] }})
For more details check the API docs.
If you want to delete ALL models of a specific type, you can use:
Model.destroy({where: {}}).then(function () {});
This will delete all records of type 'Model' from database. Tested with mysql;
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