Nearby lessons
18 of 22🧩 MongoDB: Array and Array Aggregation Operators
MongoDB provides a wide range of Array Operators that help you manipulate, transform, and analyze arrays inside documents.
You can extract elements, merge arrays, filter items, and even perform computations using aggregation pipelines.
📚 Initial Data Setup — studentsArr Collection
Example01
Loading editor…
1️⃣ $arrayElemAt — Get Element at Index
Example02
Loading editor…
2️⃣ $firstN — First N Elements
Example03
Loading editor…
3️⃣ $lastN — Last N Elements
Example04
Loading editor…
4️⃣ $maxN — N Largest Values
Example05
Loading editor…
5️⃣ $minN — N Smallest Values
Example06
Loading editor…
6️⃣ $slice — Extract Subarray
Example07
Loading editor…
7️⃣ $sortArray — Sort Elements
Example08
Loading editor…
8️⃣ $reverseArray — Reverse Order
Example09
Loading editor…
9️⃣ $size — Array Length
Example10
Loading editor…
🔟 $in — Check Membership
Example11
Loading editor…
1️⃣1️⃣ $indexOfArray — Find Element Index
Example12
Loading editor…
1️⃣2️⃣ $isArray — Check If Field Is Array
Example13
Loading editor…
1️⃣3️⃣ $map — Transform Each Element
Example14
Loading editor…
1️⃣4️⃣ $filter — Filter Elements
Example15
Loading editor…
1️⃣5️⃣ $reduce — Compute from Array
Example16
Loading editor…
1️⃣6️⃣ $range — Generate Sequence
Example17
Loading editor…
1️⃣7️⃣ $concatArrays — Merge Arrays
Example18
Loading editor…
1️⃣8️⃣ $zip — Pair Arrays
Example19
Loading editor…
1️⃣9️⃣ $arrayToObject — Convert Array → Object
Example20
Loading editor…
2️⃣0️⃣ $objectToArray — Convert Object → Array
Example21
Loading editor…
Finished this lesson?
Mark it as complete to track your progress and see technology completion stats.