Query the embedded document and query the normal document is exactly the same;
For example:
> db.post.find () { "_id" : objectid ("54ace1394ba07ed75df68f90"), "Name" : { "FirstName" : "Joe", "LastName" : "Schome" }, " Age " : 28 } { " _id " : objectid (" 54ace14a4ba07ed75df68f91 " ), "name" : { "FirstName" : "snail", "LastName" : "Yu"  }, "Age" : 29 } { "_id" : objectid (" 54ace18d4ba07ed75df68f92 "), " name " : { " FirstName " : " Sunny ", " LastName " : "WU" }, "Age" : 26 }> db.post.find ({"name": {"FirstName": "Joe", " LastName ":" Schome "}) { " _id " : objectid (" 54ace1394ba07ed75df68f90 "), " Name " : { FirstName" : "Joe", "LastName" : "Schome" }, "age " : 28 } &nbsP; >
Query embedded documents must match exactly, if the order is wrong is not the query;
We can change to "." Pattern to query the embedded document, so that there is no need for exact matching, or the order of irrelevant;
For example:
> Db.post.find ({"Name.firstname": "Joe"}) {"_id": ObjectId ("54ace1394ba07ed75df68f90"), "name": {"FirstName": "Jo E "," LastName ":" Schome "}," Age ": >
This article is from the "Margin with Wish" blog, please be sure to keep this source http://281816327.blog.51cto.com/907015/1600247
"MongoDB Learning Note 18" MongoDB query: Find query inline document