Just like arrays, we also want to search inside hashes. Searching inside hashes involves keys and values. Let's assume that the book
object looks as follows (that is, a hash instead of an array):
{ categories: { 'drama': 1, 'thriller': 2 }, }
We can search for all books that have the drama
set as 1:
> db.books.find({ "categories.drama" : 1 })
Notice that we access hash fields just like standard JSON object access.
3.142.164.100