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:
const res = await Character.remove({ name: 'Eddard Stark' });
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.
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .