summaryrefslogtreecommitdiff
path: root/jstests/core/exhaust.js
blob: 7e6c139d36747096167617c2760ee31af05e30fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// @tags: [requires_getmore]

(function() {
'use strict';

var c = db.exhaustColl;
c.drop();

const docCount = 4;
for (var i = 0; i < docCount; i++) {
    assert.commandWorked(c.insert({a: i}));
}

// Check that the query works without exhaust set
assert.eq(c.find().batchSize(1).itcount(), docCount);

// Now try to run the same query with exhaust
try {
    assert.eq(c.find().batchSize(1).addOption(DBQuery.Option.exhaust).itcount(), docCount);
} catch (e) {
    // The exhaust option is not valid against mongos, ensure that this query throws the right
    // code
    assert.eq(e.code, 18526, () => tojson(e));
}
}());