summaryrefslogtreecommitdiff
path: root/jstests/core/exhaust.js
blob: 264c8a849b636f4ebaf4ce1769e7d712054d193f (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
26
// @tags: [requires_getmore]

(function() {
    'use strict';

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

    const docCount = 4;
    for (var i = 0; i < docCount; i++) {
        assert.writeOK(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);
    }

}());