mongodb group by
程序员文章站
2024-03-19 17:43:16
...
db.topicInfo.group({
key: {"display_num": true},
initial: {"topic": 0},
reduce: function(cur, prev) {
prev.topic=prev.topic+1;
}
});
db.topicInfo.aggregate([{$group : {dinum : "$display_num", cout : {$sum : 1}}}])
key: {"display_num": true},
initial: {"topic": 0},
reduce: function(cur, prev) {
prev.topic=prev.topic+1;
}
});
db.topicInfo.aggregate([{$group : {dinum : "$display_num", cout : {$sum : 1}}}])