Model.remove()

Parameters
  • conditions «Object»
  • [options] «Object»

  • [options.session=null] «Session» the session associated with this operation.

  • [callback] «Function»

Returns:
  • «Query»

Removes all documents that match conditions from the collection. To remove just the first document that matches conditions, set the single option to true.

Example:

  1. const res = await Character.remove({ name: 'Eddard Stark' });
  2. res.deletedCount; // Number of documents removed

Note:

This method sends a remove command directly to MongoDB, no Mongoose documents are involved. Because no Mongoose documents are involved, Mongoose does not execute document middleware.