mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
d5122c9b90
more tests for group
18 lines
366 B
JavaScript
18 lines
366 B
JavaScript
t = db.group1;
|
|
t.drop();
|
|
|
|
t.save( { n : 1 , a : 1 } );
|
|
t.save( { n : 2 , a : 1 } );
|
|
t.save( { n : 3 , a : 2 } );
|
|
t.save( { n : 4 , a : 2 } );
|
|
t.save( { n : 5 , a : 2 } );
|
|
|
|
|
|
res = t.group( { key : { a : true } ,
|
|
reduce: function(obj,prev) { prev.count++; },
|
|
initial: { count: 0 }
|
|
}
|
|
);
|
|
|
|
printjson( res );
|