redis-oplog
redis-oplog copied to clipboard
findOne query on server collections with startCaching() returns doc when it shouldn't
On the Mongo console:
meteor:PRIMARY> db.users.findOne({_id:"ZqRoBNapiGcQTtTBT", nonExistentField: "nonExistentValue"})
null
Which is expected. But in the Meteor shell and in server side app code:
> Meteor.users.findOne({_id:"ZqRoBNapiGcQTtTBT", nonExistentField: "nonExistentValue"})
{
_id: 'ZqRoBNapiGcQTtTBT',
...
}
Which shouldn't be happening. This only happens on collections that have startCaching() on (e.g. Meteor.users.startCaching()) in the server code.
As long as there's an _id that matches, it doesn't matter what other fields there are, the findOne method returns the document. This is not the case for find, which works as expected.
This unexpected behaviour of the findOne method only happens on the server for collections with caching started; it works as expected on the client.