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.
15 lines
427 B
JavaScript
15 lines
427 B
JavaScript
// confirm that undefined no longer counts as 0 in $avg
|
|
c = db.c;
|
|
c.drop();
|
|
c.save({a:1});
|
|
c.save({a:4});
|
|
c.save({b:1});
|
|
assert.eq(c.aggregate({$group:{_id: null, avg:{$avg:"$a"}}}).toArray()[0].avg, 2.5);
|
|
|
|
// again ensuring numberLongs work properly
|
|
c.drop();
|
|
c.save({a:NumberLong(1)});
|
|
c.save({a:NumberLong(4)});
|
|
c.save({b:NumberLong(1)});
|
|
assert.eq(c.aggregate({$group:{_id: null, avg:{$avg:"$a"}}}).toArray()[0].avg, 2.5);
|