summaryrefslogtreecommitdiff
path: root/jstests/core/eval2.js
blob: 6e39bb4a7bde13c933cfb6fc07294e0f10e0a011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

t = db.eval2;
t.drop();
t.save({a:1});
t.save({a:1});

var f = db.group(
    {
        ns: t.getName(),
        key: { a:true},
        cond: { a:1 },
        reduce: function(obj,prev) { prev.csum++; } ,
        initial: { csum: 0}
    }
);

assert(f[0].a == 1 && f[0].csum == 2 , "on db" );  

var f = t.group(
    {
        key: { a:true},
        cond: { a:1 },
        reduce: function(obj,prev) { prev.csum++; } ,
        initial: { csum: 0}
    }
);

assert(f[0].a == 1 && f[0].csum == 2 , "on coll" );