Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
656 stars 90 forks source link

After update hook does not use direct find #296

Closed jdgjsag67251 closed 1 year ago

jdgjsag67251 commented 1 year ago

The after update hooks do not get called if the update modifies the condition in the find operation:

Collection.before.find((userId, selector, options = {}) => {
  selector.removedAt = { $exists: false };

  return true;
});

// This gets called
Collection.before.update((userId, doc) => {
  console.log("Before update", doc);
});

// This does not get called
Collection.after.update((userId, doc) => {
  console.log("After update", doc);
});

Collection.update(someId, { $set: { removedAt: new Date() } });

To me it would make sense if the after update hook would use a direct find, bypassing the before find hooks. Or at least give us the option to determine if the find is used to run the after update hooks.

github-actions[bot] commented 1 year ago

Thank you for submitting this issue!

We, the Members of Meteor Community Packages take every issue seriously. Our goal is to provide long-term lifecycles for packages and keep up with the newest changes in Meteor and the overall NodeJs/JavaScript ecosystem.

However, we contribute to these packages mostly in our free time. Therefore, we can't guarantee you issues to be solved within certain time.

If you think this issue is trivial to solve, don't hesitate to submit a pull request, too! We will accompany you in the process with reviews and hints on how to get development set up.

Please also consider sponsoring the maintainers of the package. If you don't know who is currently maintaining this package, just leave a comment and we'll let you know.

StorytellerCZ commented 1 year ago

Fix published in matb33:collection-hooks@1.2.2