Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation on the behavior of before.update hook with muti true #281

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,14 @@ test.before.update(function (userId, doc, fieldNames, modifier, options) {
});
```

__Important__: Note that we are changing `modifier`, and not `doc`.
__Important__:

1. Note that we are changing `modifier`, and not `doc`.
Changing `doc` won't have any effect as the document is a copy and is not what
ultimately gets sent down to the underlying `update` method.

2. When triggering a single update targeting multiple documents using the option `multi: true` (see [Meteor documentation](https://docs.meteor.com/api/collections.html#Mongo-Collection-update)), the `before.update` hook is called once per document about to be updated, **but** the collection update called afterwards remains a single update (targetting multiple documents) with a single modifier. Hence it is not possible at the time to use `before.update` to create a specific modifier for each targeted document.

--------------------------------------------------------------------------------

### .before.remove(userId, doc)
Expand Down