I have my mongo data as follows: group:{"name":group1, members: [{"id":1,"name": "member1"},{"id":2,"name": "member2"}]}
I would like to this collection 'group' to fetch all the groups where a person with 'id=1' is part of. The complication is that 'members' is a collection.
You can do it with simple find:
db.groups.find({'members.id':personId})
From documentation: If the array holds embedded documents, you can query for specific fields in the embedded documents using dot notation.
The query will check each element in the array for matching specific field and if there is any match the whole document will be returned.