Reno
Reno

Reputation: 2829

Querying an array of array in mongoDb

I have this document

{ "_id" : ObjectId("53c27ddf6f449b0572e8af95"), "Data" : [ [ { "_id" : 1, "Dados" : "dia:10:#mes:Outubro:#ano:1986:#hora:07:minuto:29:#segundo:16" } ] ] }

Tried this

db.data.find({ Data: {$in: {$elemMatch { _id: {$gte: 2}}}}})

and tried this

db.data.find({Data: {$elemMatch:{$elemMatch:{$in:[_id: 2]}}}})

none worked =\

what i want is to find the id = 1

I hope you guys can help me out, because i don't know what else to do. i tried this code from this link Querying an array of arrays Thanks for your attention.

Upvotes: 1

Views: 167

Answers (1)

dark_shadow
dark_shadow

Reputation: 3573

You can do it like this:

db.data.find({"Data":{$elemMatch:{$elemMatch:{_id:1}}}})

Upvotes: 2

Related Questions