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

156
Views
Why is the result an empty array?

I use mongodb for my project.

when I put in this code - db.find( {"N": {$eq:1} } ) , the result is a empty array.

but when I put this code - db.find({$where : function(){return(this.N==1)}}), the result is the array that I want.

I think two codes are same. why is the result of first code an empty array?

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

0

The value is not a number as you claim, the syntax == is different than the strict eq operator === ( which is the equivalent~ of Mongo's $eq ) as can be seen in this example

1 == `1`

> true

While the strict operator

1 === '1'

> false

So you just need to change the code to match the string '1', like so:

db.find( {"N": {$eq:'1'} } 

Or if you want to support both cases:

db.find( {"N": {$in: [1, '1']} } 

I recommend you fix your schema and db to make sure it's aligned to what you believe the structure should be.

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!