Collection.before.findOne does NOT modify selector when a string is used
KoenLav opened this issue · comments
Koen [XII] commented
When we use collection.:
- findOne;
- find;
- update;
with a string selector, rather than an object, the before hook will not update the selector properly in Meteor 1.6.1 on the server (have not verified on the client side).
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!