6
Foundational Examples: Filtering, Grouping, and Unwinding
This chapter provides examples of common data manipulation patterns used in many aggregation pipelines, which are relatively straightforward to understand and adapt. By getting baseline knowledge with these foundational examples, you will be well positioned to tackle the more advanced examples later in this book.
This chapter will cover the following:
- Finding the most recent subset of data
- Grouping and summarizing data
- Unwinding arrays and grouping them differently
- Capturing a list of unique values
Filtered top subset
First, you will look at an example that demonstrates how to query a sorted subset of data. As with all subsequent examples, this first example provides the commands ...
Get Practical MongoDB Aggregations now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.