Given the following collection:
> db.a.find()
{ "_id" : 1, "n" : 1, "x" : [ { "num" : 1 }, { "num" : 2 }, { "num" :
3 } ] }
{ "_id" : 2, "n" : 2, "x" : [ { "num" : 2 }, { "num" : 3 }, { "num" :
5 } ] }
You can find the document whose "x" array contains an embedded
document containing a value of "num" greater than 4 by using dot
notation:
> db.a.find({"x.num":{$gt:4}})
{ "_id" : 2, "n" : 2, "x" : [ { "num" : 2 }, { "num" : 3 }, { "num" :
5 } ] }
The documentation on querying embedded documents with Mongo may be
found here:
http://www.mongodb.org/display/DOCS/Dot+Notation+%28Reaching+into+Objects%29
The above link also contains a section on how the $elemMatch operator
may be used in a similar situation.
Documentation on $gt and other operators can be found in the "Advanced
Queries" documentation:
http://www.mongodb.org/display/DOCS/Advanced+Queries
Hopefully the above will help you to make your desired queries. If
you have any additional questions, the Mongo Community is here to help!