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

212
Views
in mongodb the $or operator takes precedence over a simple equal (key: value)?

I wonder if it will evaluate the parent within the '$ or' statement or the one (key / value), what takes precedence or what is the expected behavior and why?

db.collection.find({ 
    parent: '2kzW57uhwthPFNyB9',
    access: null,
    '$or': [ { owner: 'PBjjLpK9fQi4qyTd4' },
      { parent: { $in: ['2kzW57uhwthPFNyB9', '6we357uhwthPFwerr'] } } ]
})

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

{
  parent: '2kzW57uhwthPFNyB9',//condition1
  access: null,//condition2
  '$or': [
    {
      owner: 'PBjjLpK9fQi4qyTd4'//condition 3.0
    },
    {
      parent: {//condition 3.1
        $in: [
          '2kzW57uhwthPFNyB9',
          '6we357uhwthPFwerr'
        ]
      }
    }
  ]
}

It is and condition when you specify comma separated conditions in find.

You have 4 conditions as I named above.

It works like condition1 AND condition 2 AND (condition 3.0 OR condition 3.1)

So no precedence.

over 4 years ago · Santiago Trujillo 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!