Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
MongoDB Ignoring Filter

Either I'm missing something or is this a possible Node.js driver issue?

const users = await User.find({ 'test.test': { $gt: 0 } }).lean();

None of my User documents contain the test object, therefore none should meet this filter's criteria. However, instead of returning no documents, it's returning all of my user documents. According to the documentation, it should only ever return all of the documents in a collection if no/empty filters are passed?

Edit: I said ignoring filter as it only seems to occur when applying nested filters on undefined properties. For instance, if I add more filter conditions that a few documents meet they'll apply *correctly. Example: User.find({ username: { $exists: true }, 'test.test': { $gt: 0 } }) returns only the user documents where username exists, however they still don't have the test object.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The issue was resolved by setting the Mongoose Schema strictQuery option to false.

https://mongoosejs.com/docs/guide.html#strictQuery

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!