我正在尝试使用MongoDB查询(版本3.2)计算与医生ID相对应的平均值
doctorsReview.aggregate(
{
$group: {
_id: "doctors_id",
averageRating: { $avg: "$rating" }
}
}, function(error, result){
if(error)
console.log('cant calculate the average');
else
console.log(result);
});
我收到错误
doctorsReview.aggregate is not a function
TIA。