Files
mongo/jstests/core/cursor2.js

25 lines
593 B
JavaScript
Raw Normal View History

2009-01-26 23:28:26 -05:00
/**
* test to see if the count returned from the cursor is the number of objects that would be
*returned
2009-01-26 23:28:26 -05:00
*
* BUG 884
*/
function testCursorCountVsArrLen(dbConn) {
var coll = dbConn.ed_db_cursor2_ccvsal;
coll.drop();
coll.save({a: 1, b: 1});
coll.save({a: 2, b: 1});
coll.save({a: 3});
2009-01-26 23:28:26 -05:00
var fromCount = coll.find({}, {b: 1}).count();
var fromArrLen = coll.find({}, {b: 1}).toArray().length;
2009-01-26 23:28:26 -05:00
assert(fromCount == fromArrLen,
"count from cursor [" + fromCount + "] != count from arrlen [" + fromArrLen + "]");
2009-01-26 23:28:26 -05:00
}
testCursorCountVsArrLen(db);