This repo is showing the examples for the top 5 essential aggregation pipelines in MongoDB
You can install MongoDB version 6.0 from here and can also use the MongoDB Atlas to try out these examples.
We will be using 2 sample data sets for this demo.
The first one is the products dataset and second one is the orders sample dataset. Both of these datasets are available in the data folder.
- $match
- $group
- $project
- $lookup
- $unwind
Below are some more aggregation examples that you can try out.
- Calculate Total Sales for Each Product Spec
- Group by date to find the total sales for each day
- Filter orders that exceed a certain price
- Find out the total revenue from each city
- Sort customers based on the number of items they purchased
You can run the examples by using the MongoDB Playground. You can follow the instructions here to get started with MongoDB Playground.