Get count of “loglevel” for each “name”

后端 未结 2 1248
[愿得一人]
[愿得一人] 2020-12-22 04:51

For example I have following collection:

db.names.find({})

{ \"_id\" : ObjectId(\"5768d9b4bc6f464899594570\"), \"name\"          


        
2条回答
  •  醉酒成梦
    2020-12-22 05:16

    If I understand correctly, you want the sum of loglevels against each name. shouldn't this help?

       db.names.aggregate([{$group:{_id:{name:"$name",loglevel:"$loglevel"},sum:{$sum:1}}}])
    

提交回复
热议问题