Files
mongo/jstests/core/single_batch.js
David Storch 62172ae65d SERVER-21797 unify cursor response commands to respond with up to 16MB of data
Find, getMore, aggregate, listIndexes, and listCollections now will
always return 16MB per batch, unless a batchSize limits the number of
response documents.
2016-01-21 15:12:04 -05:00

22 lines
608 B
JavaScript

// Test the "single batch" semantics of negative limit.
(function() {
'use strict';
var coll = db.jstests_single_batch;
coll.drop();
// Approximately 1 MB.
var padding = new Array(1024 * 1024).join("x");
// Insert ~20 MB of data.
for (var i = 0; i < 20; i++) {
assert.writeOK(coll.insert({_id: i, padding: padding}));
}
// The limit is 18, but we should end up with fewer documents since 18 docs won't fit in a
// single 16 MB batch.
var numResults = coll.find().limit(-18).itcount();
assert.lt(numResults, 18);
assert.gt(numResults, 0);
})();