Christian Stewart
Christian Stewart

Reputation: 15519

Search by element of an object in a array

Say I have the following object:

{
    players: [{_id: "someid"}]
}

How can I query this collection for all objects that have an object in players that has the _id of someid?

Upvotes: 0

Views: 63

Answers (1)

Sergio Tulentsev
Sergio Tulentsev

Reputation: 230521

db.collection.find({'players._id': 'someid'})

It's called dot notation.

Upvotes: 1

Related Questions