📄️ 👐 Types of arrays
A JSON array can contain simple values (scalar values) or objects. In our data, books have a scalar array of the genres this book belongs to. It also has several arrays of objects, like the authors of a book, attributes and reviews.
📄️ 👐 Simple arrays
👐 Get all the Science Fiction Books
📄️ 👐 Searching inside Objects in arrays
In our books, we're using the Attribute Pattern to have different attributes in our documents. As we can see in the sample doc, we have an attributes array, containing several objects, each with the same structure:
📄️ 🦸 Size of an array
What if we want to know how many aliases an author has? To do that, we can use $size, adding the array field that we're interested in: