Destroys all records in your database that match the given criteria.
| Description | Accepted Data Types | Required ? | |
|---|---|---|---|
| 1 | Find Criteria | {},[{}], string, int |
Yes |
| 2 | Callback | function |
No |
| Description | Possible Data Types | |
|---|---|---|
| 1 | Error | Error |
| 2 | Deleted Records | [{}] |
User.destroy({name:'Flynn'}).exec(function deleteCB(err){
console.log('The record has been deleted');
});
// If the record existed, then it has been deleted
// Don't forget to handle your errorsIf you want to confirm the record exists before you delete it, you must first perform a find() Any string arguments passed must be the ID of the record.