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

#296: After update direct find #297

Conversation

jdgjsag67251
Copy link
Contributor

@jdgjsag67251 jdgjsag67251 commented Jan 31, 2023

Fixes issue #296

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.

Copy link
Member

@StorytellerCZ StorytellerCZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@StorytellerCZ
Copy link
Member

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

@jdgjsag67251
Copy link
Contributor Author

Thanks! I've updated the readme.

@StorytellerCZ StorytellerCZ merged commit 46caa3c into Meteor-Community-Packages:master Mar 31, 2023
@StorytellerCZ StorytellerCZ linked an issue Mar 31, 2023 that may be closed by this pull request
@StorytellerCZ
Copy link
Member

Published in matb33:collection-hooks@1.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After update hook does not use direct find
3 participants