Meteor-Community-Packages / meteor-collection-hooks

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

Collection.before.findOne does NOT modify selector when a string is used #241

Closed KoenLav closed 3 years ago

KoenLav commented 6 years ago

When we use collection.:

Example:

someCollection.before.findOne(function(userId, selector) {
  selector = selector || {};

  if (typeof selector === 'string') {
    selector = {
      _id: selector,
    };
  }

  selector.someKey = 'someValue';
});

When we use findOne with a string selector the combination of someKey and someValue is ignored, when we use it with an object selector it is applied!