Find and findOne return values with {fieldName:undefined} query

Hi all,

We are using Meteor version 2.12 with mongoDB 6.0.3 coming from the meteor install.

When doing something like MyCollection.find({fieldName:undefined}).fetch(); or MyCollection.findOne({fieldName:undefined});

the query returns documents where fieldName is definitely defined.

Is this an expected behavior ?
I was expecting having at most documents where fieldName does not exist but nothing more.

Thanks a lot,


That query is equal to {}, for that you should use { field: { $exists: false } } or { field: null }


Thanks for your reply.

Actually what I was trying to say is that sometime we do a query like this: MyCollection.findOne({fieldName: value});

But for some reason sometimes “value” is undefined.

Hence we were expecting to have no results, not the first element found in the db…

Do you think this is expected ?

Yes, thats expected behaviour. You will need to check your param so that its not undefined in that case.

Hello, sorry for my late reply.

Thanks a lot for your answer. Bests !

1 Like

Breaking changes - Meteor Changelog v1.6.1