Sequencing stages
Here is a cursor, followed by four aggregation pipeline stages:
cursor = (db.laureates.find(
projection={"firstname": 1, "prizes.year": 1, "_id": 0},
filter={"gender": "org"})
.limit(3).sort("prizes.year", -1))
project_stage = {"$project": {"firstname": 1, "prizes.year": 1, "_id": 0}}
match_stage = {"$match": {"gender": "org"}}
limit_stage = {"$limit": 3}
sort_stage = {"$sort": {"prizes.year": -1}}
What sequence pipeline
of the above four stages can produce a cursor db.laureates.aggregate(pipeline)
equivalent to cursor
above?
Este exercício faz parte do curso
Introduction to MongoDB in Python
Exercício interativo prático
Transforme a teoria em ação com um de nossos exercícios interativos
