0

I'm trying to retrieve documents which can satisfy all the conditions in this query from a embedded document in an array.It's retrieving documents of any of the condition satisfied.

db.getCollection('CollectionName').find(
    { $and: [{ "users.type" : "user" },
       { "users.status" : "2"},
       {"users.userId" : ObjectId("Some Object Id")} ]}
Rishi
  • 7
  • 4
  • 1
    So what's the problem in the above query??? – Subburaj Jun 06 '17 at 05:52
  • I'm not getting proper Data from the query, even if the given conditions are not satisfied, it's retrieving all the doccuments with the any of the given conditions. – Rishi Jun 06 '17 at 06:05
  • By guess is that problem is with the last condition `ObjectId("Some Id")`. Try without ObjectId – Subburaj Jun 06 '17 at 06:22
  • Thank You, query without objectId is working fine, but in my condition i have to filter data with the ObjectId. How can I filter with the Id? – Rishi Jun 06 '17 at 06:59
  • Why it's not querying with the ObjectId?? – Rishi Jun 06 '17 at 09:58

0 Answers0