Searching inside arrays

Unlike most SQL databases, MongoDB can store values inside arrays and hashes. Now, we shall see how we can search inside arrays.

Tip

Did you know that most of the operators we learned about earlier, could be used directly on arrays inside a document just like normal fields? For example:

> db.books.insert( { "categories" : [ " Drama", "Action"] } )

> db.books.find( { categories : { $ne : "Romance"} } )

This will return the document we inserted previously. Isn't that cool?!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.27.99