db.collectionName.aggregate([{$match: {"whereColumn": whereCondition}}, {$unwind: '$NestedcolumnToWorkOn}, {$group: {_id: null, "avg": {$avg: "$NestedcolumnToWorkOn.fieldName"}}}], function(err, average) {
console.log(average[0].avg);
});
console.log(average[0].avg);
});
No comments:
Post a Comment