7. Data Aggregation
Activity 7.01: Putting Aggregations into Practice
Solution:
Perform the following steps to complete the activity:
- First, create the scaffold code:
// Chapter_7_Activity.js var chapter7Activity = function() { Â Â Â Â var pipeline = []; Â Â Â Â db.movies.aggregate(pipeline).forEach(printjson); } Chapter7Activity()
- Add the first match for documents older than 2001:
var pipeline = [ Â Â Â Â {$match: { Â Â Â Â Â Â Â Â released: {$lte: new ISODate("2001-01-01T00:00:00Z")} Â Â Â Â }} Â Â ];
- Add a second match condition for movies with at least one award win:
    {$match: {         released: {$lte: new ISODate("2001-01-01T00:00:00Z")},         "awards.wins": {$gte: 1},     }}
- Add a
sort
condition...