Files
mongo/jstests/aggregation/bugs/server5209.js
Mathias Stearn 061a086641 SERVER-10165 aggregate() shell helper now returns a cursor
The actual change is in src/mongo/shell/collection.js with the remaining changes
to adjust tests to the new api.

The "ideal" arguments are now an array of pipeline ops and an optional object
with extra top-level options for the command (such as {explain: true}. For
backwards compatibility, we still support the varargs style where each argument
is a pipeline stage, but there is no way to specify extra parameters in this
mode.
2013-10-08 17:35:02 -04:00

21 lines
552 B
JavaScript

// use qa
db = db.getSiblingDB('qa');
db.aggtype.drop();
db.aggtype.insert({key: NumberInt(24), value: 17});
db.aggtype.insert({key: NumberLong(24), value: 8});
db.aggtype.insert({key: 24, value: 5});
db.aggtype.insert({key: NumberInt(42), value: 11});
db.aggtype.insert({key: NumberLong(42), value: 13});
db.aggtype.insert({key: 42, value: 6});
var at = db.aggtype.aggregate(
{$group: {
_id: "$key",
s: {$sum: "$value"}
}}
).toArray();
assert(at[0].s == 30, 'server5209 failed');
assert(at[1].s == 30, 'server5209 failed');