Strange collectiob.findOne behaviour

Hi all.
I have a simple query

let result = collection.findOne({myParam: myQueryParam}

Now, when ‘myQueryParam’ is undefined, the query returns the first row in that collection! That cannot be right? It basically behaves like collection.findOne()

Is this a known problem with certain versions (I run 2.14) or is it… something else?

That’s expected in mongodb.

collection.findOne({ myParam: undefined });

is the same as

collection.findOne({})

Really? That’s… absurd :slight_smile:

well you know, it’s mongodb. in order for it to be flexible it sometimes leads to unintuitive behavior.