var media = Userhistory.getDataSource().connector.collection('media');
media.aggregate([
{ $match: { mediaStatus: 3 } },
{ $group: {
_id: 1,
totalSize: { $sum: "$mediaFileSize" },
}}
], function(err, data) {
console.log("data",data);
//In data Iam getting AggregationCursor object
//not the result
});
I have used the above code to perform aggregation in loopback. My expected output of "data" in above code is the array of results, But I am getting AggregationCursor object
Note loopback-connector-mongodb version - "^3.4.1"
Try to get result using promise
media.aggregate([...]).then((data) => {
console.log(data)
})