0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00
mongodb/jstests/group1.js
2009-06-08 10:54:55 -04:00

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 );