1
turing 2014 年 4 月 30 日
搜索一下 $inc 操作符
|
2
liangdi 2014 年 4 月 30 日 via Android
有$sum
|
4
hydrazt 2014 年 4 月 30 日
mapreduce
|
6
hydrazt 2014 年 4 月 30 日
|
7
turing 2014 年 4 月 30 日
累加求和用 mapReduce
model.mapReduce({ map: function() { emit(this.earn, 1) }, reduce: function(key, values){ return Array.sum(values); }, query: { ... // 查询参数 } }); http://docs.mongodb.org/manual/core/map-reduce/ |
9
wbean 2014 年 4 月 30 日 mongo中简单的统计需求不用祭出mapreduce这种大杀器。
Aggregation就可以了。 通过一些基础管道操作,如$project,$match,$group,$limit,$skip,$sort 和 一些 常用表达式如$sum,$avg,$min,$max 等实现基础的统计需求 db.collection.aggregate( [ $match:{} $group:{$_id:"",total:{$sum:"$amount"}} ] ); |
10
benleewindy 2014 年 5 月 1 日
@turing Reduce本身就是对collection做迭代归并操作,肯定能满足,简单需求似乎过重。。。。
|