@@ -31,7 +31,6 @@ In document middleware functions, `this` refers to the document. To access the m
3131
3232* [ validate] ( api/document.html#document_Document-validate )
3333* [ save] ( api/model.html#model_Model-save )
34- * [ remove] ( api/model.html#model_Model-remove )
3534* [ updateOne] ( api/document.html#document_Document-updateOne )
3635* [ deleteOne] ( api/model.html#model_Model-deleteOne )
3736* [ init] ( api/document.html#document_Document-init ) (note: init hooks are [ synchronous] ( #synchronous ) )
@@ -51,7 +50,6 @@ In query middleware functions, `this` refers to the query.
5150* [ findOneAndRemove] ( api/query.html#query_Query-findOneAndRemove )
5251* [ findOneAndReplace] ( api/query.html#query_Query-findOneAndReplace )
5352* [ findOneAndUpdate] ( api/query.html#query_Query-findOneAndUpdate )
54- * [ remove] ( api/model.html#model_Model-remove )
5553* [ replaceOne] ( api/query.html#query_Query-replaceOne )
5654* [ update] ( api/query.html#query_Query-update )
5755* [ updateOne] ( api/query.html#query_Query-updateOne )
@@ -86,7 +84,6 @@ Here are the possible strings that can be passed to `pre()`
8684* findOneAndUpdate
8785* init
8886* insertMany
89- * remove
9087* replaceOne
9188* save
9289* update
@@ -382,11 +379,11 @@ Mongoose has both query and document hooks for `deleteOne()`.
382379``` javascript
383380schema .pre (' deleteOne' , function () { console .log (' Removing!' ); });
384381
385- // Does **not** print "Removing!". Document middleware for `remove ` is not executed by default
382+ // Does **not** print "Removing!". Document middleware for `deleteOne ` is not executed by default
386383await doc .deleteOne ();
387384
388385// Prints "Removing!"
389- Model .remove ();
386+ await Model .deleteOne ();
390387```
391388
392389You can pass options to [ ` Schema.pre() ` ] ( api.html#schema_Schema-pre )
@@ -400,8 +397,8 @@ schema.pre('deleteOne', { document: true, query: false }, function() {
400397 console .log (' Deleting doc!' );
401398});
402399
403- // Only query middleware. This will get called when you do `Model.remove ()`
404- // but not `doc.remove ()`.
400+ // Only query middleware. This will get called when you do `Model.deleteOne ()`
401+ // but not `doc.deleteOne ()`.
405402schema .pre (' deleteOne' , { query: true , document : false }, function () {
406403 console .log (' Deleting!' );
407404});
0 commit comments