Nearby lessons
13 of 22📊 MongoDB: Aggregation Pipeline Operators
MongoDB’s Aggregation Framework is used to process data records and return computed results.
It works like a data processing pipeline, allowing you to filter, group, sort, and transform documents.
📚 Initial Data Setup
Example01
1️⃣ $match — Filter Documents
Example02
2️⃣ $count — Count Documents
Example03
3️⃣ $sort — Sort Documents
Example04
4️⃣ $sortByCount — Count and Sort
Example05
5️⃣ $project — Show Specific Fields
Example06
6️⃣ $limit — Limit Results
Example07
7️⃣ $skip — Skip Results
Example08
8️⃣ $sample — Get Random Documents
Example09
9️⃣ $group — Group & Aggregate Data
Example10
🔟 $sum — Count Students per Class
Example11
1️⃣1️⃣ $max — Find Oldest Student per Class
Example12
1️⃣2️⃣ $min — Find Youngest Student per Class
Example13
1️⃣3️⃣ $push — Collect All Names by Class
Example14
1️⃣4️⃣ $addToSet — Collect Unique Names by Class
Example15
1️⃣5️⃣ $first — Get First Student per Class
Example16
1️⃣6️⃣ $last — Get Last Student per Class
Example17
$top — Top Age Student per Class
Example18
$topN — Top 2 Students by Age per Class
Example19
$bottom — Student with Lowest Age per Class
Example20
$bottomN — Bottom 2 Students by Age per Class
Example21