Field Paths and Sets
Previously, we confirmed -- via a Python loop -- that for each prize, either all laureates have a 1/3 share, or none do. Now, let's do this via an aggregation (result should be an empty list):
list(db.prizes.aggregate([
{"$project": {"allThree": {"$setEquals": [____, ____]},
"noneThree": {"$not": {"$setIsSubset": [____, ____]}}}},
{"$match": {"$nor": [{"allThree": True}, {"noneThree": True}]}}]))
Which values fill the blanks?
This exercise is part of the course
Introduction to MongoDB in Python
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
