Categories
JavaScript Answers

How to destroy or delete all records in the table with Node Sequelize?

Spread the love

To destroy or delete all records in the table with Node Sequelize, we call the destroy method.

For instance, we write

db.User.destroy({
  where: {},
  truncate: true,
});

to call destroy to destroy the table linked to the User model.

We set truncate to true to remove all the data in it.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.