โ MongoDB learning pathMongoDB ยท Module 6 of 10
Aggregation pipeline
Transform and analyse data with stages.
๐ Key ideas
- aggregate([ stage1, stage2, ... ]) processes documents step by step.
- $match filters; $group groups and sums.
- $project reshapes; $sort orders; $limit trims.
- $lookup joins another collection; $unwind flattens arrays.
- Use for reports: totals, averages, counts.
๐ก Real-life example: The pipeline is a factory line: each station (stage) changes the product before passing it on.
$matchFilter stage
$groupGroups and calculates
$unwindSplits an array into documents
$projectReshapes fields