Skip to content

Commit

Permalink
Merge pull request #9530 from mustafaKamal-fe/patch-1
Browse files Browse the repository at this point in the history
Update middlewar.pug file
  • Loading branch information
vkarpov15 authored Nov 8, 2020
2 parents 61af2af + ec8ae00 commit fcc1341
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/middleware.pug
Original file line number Diff line number Diff line change
Expand Up @@ -329,17 +329,17 @@ block content
You can pass options to [`Schema.pre()`](/docs/api.html#schema_Schema-pre)
and [`Schema.post()`](/docs/api.html#schema_Schema-post) to switch whether
Mongoose calls your `remove()` hook for [`Document.remove()`](/docs/api.html#model_Model-remove)
or [`Model.remove()`](/docs/api.html#model_Model.remove):
or [`Model.remove()`](/docs/api.html#model_Model.remove). Note here that you need to set both `document` and `query` properties in the passed object:

```javascript
// Only document middleware
schema.pre('remove', { document: true }, function() {
schema.pre('remove', { document: true, query: false }, function() {
console.log('Removing doc!');
});

// Only query middleware. This will get called when you do `Model.remove()`
// but not `doc.remove()`.
schema.pre('remove', { query: true }, function() {
schema.pre('remove', { query: true, document: false }, function() {
console.log('Removing!');
});
```
Expand Down

0 comments on commit fcc1341

Please sign in to comment.