.destroy( criteria , [callback] )

Purpose

Destroys all records in your database that match the given criteria.

Overview

Parameters

Description Accepted Data Types Required ?
1 Find Criteria {},[{}], string, int Yes
2 Callback function No

Callback Parameters

Description Possible Data Types
1 Error Error
2 Deleted Records [{}]

Example Usage

  1. User.destroy({name:'Flynn'}).exec(function deleteCB(err){
  2. console.log('The record has been deleted');
  3. });
  4. // If the record existed, then it has been deleted
  5. // Don't forget to handle your errors

Notes

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