列出唯一数据项db.getCollection('records').aggregate([{$match:{is_job:true}},])按指定字段统计.getCollection('records').aggregate([{$match:{is_job:true}},{$group:{_id:"$gname",count:{$sum:1}}},])在组中定义数据返回的字段现在有id(id表示为主键)和count字段按指定字段排序db.getCollection('records').aggregate([{$match:{is_job:true}},{$group:{_id:"$gname",count:{$sum:1}}},{$sort:{count:-1}}])延伸阅读MongoDB统计唯一数据分组https://blog.csdn.net/weixin_...MongoDB的skip,limit,sortexecutionorder,andaggregatehttps://blog.csdn.net/jason_c...
