Files
mongo/jstests/aggregation/bugs/server4899.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
618 B
JavaScript

// test $size
load('jstests/aggregation/extras/utils.js');
c = db.server4899;
c.drop();
c.save({arr:[]});
c.save({arr:[1]});
c.save({arr:["asdf", "asdfasdf"]});
c.save({arr:[1, "asdf", 1234, 4.3, {key:23}]});
c.save({arr:[3, [31, 31, 13, 13]]});
result = c.aggregate({$project: {_id: 0, length: {$size: "$arr"}}});
assert.eq(result.toArray(), [{length:0},
{length:1},
{length:2},
{length:5},
{length:2}]);
c.save({arr:231});
assertErrorCode(c, {$project: {_id: 0, length: {$size: "$arr"}}}, 17124);