You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Introduction to MongoDB in Python/4. Aggregation Pipelines: Let the Server Do It For You.md
+28Lines changed: 28 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -97,3 +97,31 @@ pipeline = [
97
97
print(list(db.laureates.aggregate(pipeline)))
98
98
```
99
99
[{'_id': None, 'n_prizes_total': 27}]
100
+
## 🦍 Gap years, aggregated
101
+
-[x] Make the $group stage output a document for each prize year (set "_id" to the field path for year) with the set of categories awarded that year.
102
+
-[x] Given your intermediate collection of year-keyed documents, $project a field named "missing" with the (original) categories not awarded that year. Again, mind your field paths!
103
+
-[x] Use a $match stage to only pass through documents with at least one missing prize category.
104
+
-[x] Finally, add sort documents in descending order.
0 commit comments