Skip to content

Commit 6cb5571

Browse files
authored
Merge pull request Automattic#14822 from hasezoey/fixremove7x
docs(middleware): update some more "remove" related notes
2 parents 9dcd8aa + 98e4ae9 commit 6cb5571

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

docs/middleware.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
383380
schema.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
386383
await doc.deleteOne();
387384

388385
// Prints "Removing!"
389-
Model.remove();
386+
await Model.deleteOne();
390387
```
391388

392389
You 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()`.
405402
schema.pre('deleteOne', { query: true, document: false }, function() {
406403
console.log('Deleting!');
407404
});

docs/subdocs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ doc.child;
3838
```
3939

4040
<ul class="toc">
41-
<li><a href="#what-is-a-subdocument-">What is a Subdocument?</a></li>
41+
<li><a href="#what-is-a-subdocument">What is a Subdocument?</a></li>
4242
<li><a href="#subdocuments-versus-nested-paths">Subdocuments versus Nested Paths</a></li>
4343
<li><a href="#subdocument-defaults">Subdocument Defaults</a></li>
4444
<li><a href="#finding-a-subdocument">Finding a Subdocument</a></li>

0 commit comments

Comments
 (0)