← 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