0

Need to get the data inside a array/nested array in MongoDB.

Suppose my Collection is :

{"No" : 1, "Inner":[{"Created By":"A1","Updated By":"AA1"}]}
{"No" : 2, "Inner":[{"Created By":"A2","Updated By":"AA2"}]}
{"No" : 3, "Inner":[{"Created By":"A3","Updated By":"AA3"}]}

and so on...

I Need to find document where No = 3 and Created By = A6

  • Does this answer your question? [Return only matched sub-document elements within a nested array](https://stackoverflow.com/questions/36229123/return-only-matched-sub-document-elements-within-a-nested-array) – whoami - fakeFaceTrueSoul Dec 18 '19 at 22:48

1 Answers1

0

Based on your question I think a compound query is what you are looking for:

db.collection.find( { "No": 3, "Inner.Created By": "A6" } )

I hope this helps!

DevKyle
  • 1,091
  • 6
  • 22