0

Consider the following models:

User:
  id: ObjectID

Group:
  id: ObjectID
  users: []

If I had a group collection like:

Group = [{
    id: 1,
    users: [1,2,3,4,5]
  },
  {
    id: 2,
    users: [1,6,7]
  }
]

How could I get all the Groups that container the User ID 1 in the groups.users array?

kidcapital
  • 5,064
  • 9
  • 46
  • 68
  • https://duckduckgo.com/?q=stackoverflow+mongodb+query+array+contains&t=ffab&ia=qa – str Mar 10 '17 at 13:00
  • 2
    Possible duplicate of [Find document with array that contains a specific value](http://stackoverflow.com/questions/18148166/find-document-with-array-that-contains-a-specific-value) – str Mar 10 '17 at 13:00

0 Answers0