Using the aggregation pipeline

The MongoDB aggregation pipeline framework consists of the aggregate() collection method, and a sequence of operations referred to as stages (https://docs.mongodb.com/manual/reference/operator/aggregation-pipeline/#aggregation-pipeline-stages). This sequence is referred to as a pipeline.

For illustration, let's assume that there's a collection called purchases, where each purchase has an amount of information as well as embedded customer and product objects:

We wish to generate a report on the total sales for each customer from Australia. A simple db.collection.find() command will not suffice as it is incapable ...

Get MongoDB 4 Quick Start Guide 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.