DEV Community

Discussion on: Getting started with the aggregation framework in MongoDB

Collapse
 
gcdcoder profile image
Gustavo Castillo

Nice post, but I think you have a little error in the $project example, it would be something like this:

db.restaurants.aggregate([
    { $match: { cuisine: 'Russian'}},
    { $project: {
        _id: 0,
        name: 1,
        stars: 1
    }}
])

The $project object should be outside the $match one :simple_smile:

Collapse
 
damcosset profile image
Damien Cosset

You're absolutely right. Thank you for catching this! I edited the post <3