Files
mongo/jstests/core/query/explain/explain4.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

25 lines
461 B
JavaScript

// Test that limit is applied by explain.
// @tags: [
// assumes_read_concern_local,
// requires_fcv_82,
// ]
let t = db.jstests_explain4;
t.drop();
t.createIndex({a: 1});
for (let i = 0; i < 10; ++i) {
t.save({a: i, b: 0});
}
let explain = t
.find({a: {$gte: 0}, b: 0})
.sort({a: 1})
.hint({a: 1})
.limit(5)
.explain(true);
// Five results are expected, matching the limit spec.
assert.eq(5, explain.executionStats.nReturned);