Filtering in Mongoose / MongoDB 'find' with non-existent value returns all results

Viewed 22

I am using Mongoose v6.3.8. I might have a basic misunderstanding about how Mongoose / MongoDB works, but if I do...

model.find({ nonExistentKey: 'anyValue' });

it returns all documents, even though nonExistentKey doesn't show up anywhere in my database.

I was expecting it to return no documents since no documents use nonExistentKey.

Can someone please explain this behavior?

Thank you.

0 Answers
Related