1

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.

1

1 Answer 1

1

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)
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.