Searching inside embedded documents is exactly like searching inside hashes. This seems to make sense because MongoDB saves every document as a hash.
The following is an example of an embedded document:
{ "_id" : ObjectId("6234a68bfed0eb0beabcd234"), "name" : "The Adventures of Sindbad", "category" : { "_id" : ObjectId("5ad6f68bfed0eb0be1231213"), "name" : "Adventure", } }
To fetch the category
object it's exactly the same way as searching inside a hash:
> db.books.find( { "category.name" : "Adventure" }
And just like that, searching inside arrays, hashes, and embedded documents have almost the same syntax!
3.149.23.167