snakom23
snakom23

Reputation: 203

Find array in array data in MongoDB

I want find in this document groups:

      "document": {
        "groups": [
          {
            "id": "5ccd5f7f34f82b0e3315b2f6"
          },
          {
            "id": "73b43unbfkfmdmddfdf84jjk"
          }
         ]
      }

are contains some of my query array groups ID:

[ '5ccd5f7f34f82b0e3315b2f6',
 '5cdeded7ace07216f5873b5d',
 '5cdee5d114edac2cc00bb333' ]

Upvotes: 1

Views: 91

Answers (1)

Tom Slabbaert
Tom Slabbaert

Reputation: 22276

A simple find query suffices:

db.collection.find({ 'groups.id' : {$in : [ '5ccd5f7f34f82b0e3315b2f6',
                                            '5cdeded7ace07216f5873b5d',
                                            '5cdee5d114edac2cc00bb333' ] }})

Upvotes: 1

Related Questions