1

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.

1 Answer 1

2

You can do it like this:

db.data.find({"Data":{$elemMatch:{$elemMatch:{_id:1}}}})
Sign up to request clarification or add additional context in comments.

7 Comments

You can remove it. It will also work after removing the "". Actually its a good habit to put fields in "" because sometimes you might be using nested fields and in that case using the field without "" will cause an error. For now, you can remove it.
Ah i see, thanks, i'll keep this habit, lets say i want to show everything, i should use db.data.find({"Data":{$elemMatch:{$elemMatch:{_id:{$gt:0}}}}}), right? There's another way ? That's my last question, and thanks you very much dark_shadow
What do you mean by show everything ? If you are trying to say you want all documents where _id > 0 then your query is right.
Yes, show all documents, i have another problem now, should I post it here or ask another question? is about multiple auto_increment.
Your issue seems to be different then the existing issue. You should create a separate thread for it.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.