# Arrays, Nested Fields and Results

Recipes hold lists and documents inside them. Query a field inside a field with dot notation, match values in arrays and whole items in arrays of documents, then choose which fields come back, sort them and show them a page at a time.

Updated: November 19, 2026

## [Arrays and Nested Fields](https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-arrays-and-nested-fields)

1. [Fields Inside Fields: Dot Notation](https://www.ask-codey.com/lessons/mongodb-dot-notation) (Apprentice): Dot notation names a field inside an embedded document, such as "nutrition.calories" in quotes, so a filter can test that one field instead of matching the whole embedded document.
2. [Querying Arrays: One Value, $all and $size](https://www.ask-codey.com/lessons/mongodb-querying-arrays) (Apprentice): A filter on an array field matches when any item fits, $in matches when any item is one of a list, $all asks for every value in a list, and $size counts the items; an exact array match is rarely what you want.
3. [Arrays of Documents and $elemMatch](https://www.ask-codey.com/lessons/mongodb-arrays-of-documents-and-elemmatch) (Journeyman): Dot notation reaches a field of every document in an array, such as "ingredients.name"; two such conditions can be met by two different items, and $elemMatch makes them hold for the same item.

## [Shaping Results](https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-shaping-results)

1. [Choosing Fields with Projections](https://www.ask-codey.com/lessons/mongodb-projections) (Apprentice): A projection, the second argument to find, chooses which fields come back; 1 includes a field and 0 leaves it out, \_id comes along unless you leave it out, and the two can't be mixed except for \_id.
2. [Sorting and Paging: sort, limit and skip](https://www.ask-codey.com/lessons/mongodb-sorting-and-paging) (Apprentice): sort puts results in order (1 up, -1 down) with a second field to break ties, limit caps how many come back, skip passes over the pages before, and countDocuments gives the number of pages.

## [Exercise: Ingredient Search](https://www.ask-codey.com/courses/mongodb-in-depth/topics/mongodb-exercise-ingredient-search)

1. [Exercise: Ingredient Search](https://www.ask-codey.com/lessons/exercise-mongodb-ingredient-search) (Apprentice): Write six mongosh queries for Sunday Kitchen's "what can I cook with what's in my fridge?" search, from recipes with chickpeas to page 2 of the best-rated, and let the tests run each one on the 40 recipes and check what it finds.

Source: https://www.ask-codey.com/courses/mongodb-in-depth/chapters/arrays-nested-fields-and-results-in-mongodb
