Mongo average aggregation query with no group

前端 未结 3 1590
生来不讨喜
生来不讨喜 2020-12-03 21:39

I am trying to get the average of a whole field using the aggregation framework in Mongo. However i can\'t seem to find any example that uses it without a group parameter. <

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-03 22:17

    For more details please visit the following link: https://docs.mongodb.com/manual/reference/operator/aggregation/group/index.html
    
    db.EvaluatedSentiments.aggregate([
    {
    $group:{_id:null,avgbvc: {$avg:"$bvc"}}
    }
    ]).forEach(printjson)
    

提交回复
热议问题