mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
19 lines
280 B
JavaScript
19 lines
280 B
JavaScript
|
|
||
|
t = db.test;
|
||
|
t.drop();
|
||
|
t.save({a:1});
|
||
|
t.save({a:1});
|
||
|
|
||
|
var f = db.group(
|
||
|
{
|
||
|
ns: "test",
|
||
|
key: { a:true},
|
||
|
cond: { a:1 },
|
||
|
reduce: function(obj,prev) { prev.csum++; } ,
|
||
|
initial: { csum: 0}
|
||
|
}
|
||
|
);
|
||
|
|
||
|
assert(f[0].a == 1 && f[0].csum == 2);
|
||
|
|