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

findOne query on server collections with startCaching() returns doc when it shouldn't #25

Open
JackAdams opened this issue Oct 26, 2022 · 0 comments

Comments

@JackAdams
Copy link

JackAdams commented Oct 26, 2022

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.

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

No branches or pull requests

1 participant