Grokking MongoDB
0% completed
Aggregation Pipeline Stages
Five documents enter the pipeline below, and one document leaves it. Each of its five stages performs one small job, and the first sections of this lesson follow those stages in order. The collection is a small inventory.
db.inventory.insertMany([ { item: "apple", qty: 10, category: "fruit" }, { item: "carrot", qty: 20, category: "vegetable" }, { item: "banana", qty: 5, category: "fruit" }, { item: "broccoli", qty: 15, category: "vegetable" }, { item: "grape", qty: 8, category: "fruit" } ])
The question is: which fruit has the second largest quantity?
``
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%