MONGODB聚合函数

时间:2016-01-28 08:30:45

标签: mongodb

我正在尝试使用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。

0 个答案:

没有答案
相关问题