-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.0.0
-
Component/s: Docs
-
None
-
Empty show more show less
The aggregation example code on
http://mongodb.github.io/node-mongodb-native/3.0/tutorials/aggregation/#the-aggregation-pipeline
Should show how to process the cursor returned instead of printing cursor object.
const collection = db.collection( 'restaurants' ); collection.aggregate( [ { '$match': { "borough": "Bronx" } }, { '$unwind': '$categories'}, { '$group': { '_id': "$categories", 'Bronx restaurants': { '$sum': 1 } } } ], function(err, results) { assert.equal(err, null); console.log(results) callback(results); } );
For example, this should have shown:
const collection = db.collection( 'restaurants' ); collection.aggregate( [ { '$match': { "borough": "Bronx" } }, { '$unwind': '$categories'}, { '$group': { '_id': "$categories", 'Bronx restaurants': { '$sum': 1 } } } ], function(err, cursor) { assert.equal(err, null); cursor.toArray(function(err, document){ console.log(document); }); callback(results); } );