1

I have this data in mongodb. my query is not matching this record.

/* 1 */
{
    "_id" : ObjectId("5a60fd777f57eea025f0521d"),
    "groupname" : "my Users",
    "memberes" : [ 
        {
            "CN" : "john, miller",
            "employeeNumber" : "865",

        }, 
        {
            "CN" : "sunil, kumar",
            "employeeNumber" : "456",

        }
    ]
}

query

db.collection.find( { "memberes": { "employeeNumber" : "456"} } )

Can help me to correct this query?

Thanks SR

sfgroups
  • 18,151
  • 28
  • 132
  • 204
  • Looks at this https://stackoverflow.com/questions/48083603/mongodb-c-sharp-complex-query/48083997#48083997 It's C# but you can use the same approach for this – RICKY KUMAR Jan 18 '18 at 23:25
  • 1
    Possible duplicate of [How to query nested objects?](https://stackoverflow.com/questions/16002659/how-to-query-nested-objects) – s7vr Jan 18 '18 at 23:33

1 Answers1

0

Look at this answer and the documentation here

The corrected query according to these materials would be:

db.collection.find({ "memberes.employeeNumber" : "456"})

Syed Arefinul Haque
  • 1,123
  • 2
  • 14
  • 38