Meteor-Community-Packages / meteor-collection-hooks

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

#296: After update direct find #297

Closed jdgjsag67251 closed 1 year ago

jdgjsag67251 commented 1 year ago

Fixes issue #296

The after update hooks do not get called if the update modifies the condition in the find operation: ```js 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.
StorytellerCZ commented 1 year ago

Just one little thing. Can you add info about this into the readme. Thanks!

jdgjsag67251 commented 1 year ago

Thanks! I've updated the readme.

StorytellerCZ commented 1 year ago

Published in matb33:collection-hooks@1.2.2