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

309
Views
How to find a record by unique value inside an array in MongoDB?

I want to locate a record which has the "String to match" in his "affiliates.wallets" array. But for some reason, I'm unable to do it.

I was trying something like:

db.collection.findOne({ "affiliates.wallets": {$in: "[String to match]"}, (err, data) => console.log(err, data)})

But it returns null. So, I'm asking for help.

Simplified Wallet Schema:

Wallet {
  affiliates: {
    wallets: [String]
  }
}

P.S: I'm using findOne method because this "String to match" which I'm using to locate the record is unique and it can be located only in one record.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You don't need $in operator. You can do it like this:

db.collection.findOne({
  "affiliates.wallets": "String to match", 
}, (err, data) => {
  console.log(err, data)
})
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!