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
1️⃣ $match — Filter Documents
2️⃣ $count — Count Documents
3️⃣ $sort — Sort Documents
4️⃣ $sortByCount — Count and Sort
5️⃣ $project — Show Specific Fields
6️⃣ $limit — Limit Results
7️⃣ $skip — Skip Results
8️⃣ $sample — Get Random Documents
9️⃣ $group — Group & Aggregate Data
🔟 $sum — Count Students per Class
1️⃣1️⃣ $max — Find Oldest Student per Class
1️⃣2️⃣ $min — Find Youngest Student per Class
1️⃣3️⃣ $push — Collect All Names by Class
1️⃣4️⃣ $addToSet — Collect Unique Names by Class
1️⃣5️⃣ $first — Get First Student per Class
1️⃣6️⃣ $last — Get Last Student per Class
$top — Top Age Student per Class
$topN — Top 2 Students by Age per Class
$bottom — Student with Lowest Age per Class
$bottomN — Bottom 2 Students by Age per Class
Keep Going!MongoDB - Aggregation Operators