Get startedGet started for free

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?

This exercise is part of the course

Introduction to MongoDB in Python

View Course

Hands-on interactive exercise

Turn theory into action with one of our interactive exercises

Start Exercise