【发布时间】:2014-09-16 05:48:19
【问题描述】:
假设我的收藏有用户名、存储库名称和唯一的提交 ID。
{"name" : "a","commit_id": "078d40cc537","repo": "r1"},
{"name" : "b","commit_id": "078d40cc538","repo": "r2"},
{"name" : "c","commit_id": "078d40cc539","repo": "r3"},
{"name" : "a","commit_id": "078d40cc540","repo": "r1"},
{"name" : "c","commit_id": "078d40cc541","repo": "r1"},
{"name" : "c","commit_id": "078d40cc542","repo": "r3"},
{"name" : "d","commit_id": "078d40cc543","repo": "r1"}
我想生成一个按存储库分组的输出,其中包含 # 个不同的用户和总提交。
repo:"r1" , distinct_users:"3", total_commits:"4"
repo:"r3" , distinct_users:"1", total_commits:"2"
repo:"r2" , distinct_users:"1", total_commits:"1"
我们将不胜感激。
【问题讨论】:
标签: mongodb distinct mongodb-query aggregation-framework