diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2013-07-08 14:44:32 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2013-07-09 14:10:54 -0400 |
commit | b8f0ec598013009c56dee527e76429ffa7b8c394 (patch) | |
tree | a7cf31d7fbf6bc525f4b1ded421dad8a97aed9a5 /jstests/stages_limit_skip.js | |
parent | fedd312c424fc5f82f7be1dad13f3dd74403c4a4 (diff) | |
download | mongo-b8f0ec598013009c56dee527e76429ffa7b8c394.tar.gz |
SERVER-10026 fetch limit skip or
Diffstat (limited to 'jstests/stages_limit_skip.js')
-rw-r--r-- | jstests/stages_limit_skip.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/jstests/stages_limit_skip.js b/jstests/stages_limit_skip.js new file mode 100644 index 00000000000..9441e4cd65b --- /dev/null +++ b/jstests/stages_limit_skip.js @@ -0,0 +1,34 @@ +// Test limit and skip +t = db.stages_limit_skip; +t.drop(); + +var N = 50; +for (var i = 0; i < N; ++i) { + t.insert({foo: i, bar: N - i, baz: i}); +} + +t.ensureIndex({foo: 1}) + +// foo <= 20, decreasing +// Limit of 5 results. +ixscan1 = {ixscan: {args:{name: "stages_limit_skip", keyPattern:{foo: 1}, + startKey: {"": 20}, + endKey: {}, endKeyInclusive: true, + direction: -1}}}; +limit1 = {limit: {args: {node: ixscan1, num: 5}}} +res = db.runCommand({stageDebug: limit1}); +assert(!db.getLastError()); +assert.eq(res.ok, 1); +assert.eq(res.results.length, 5); +assert.eq(res.results[0].foo, 20); +assert.eq(res.results[4].foo, 16); + +// foo <= 20, decreasing +// Skip 5 results. +skip1 = {skip: {args: {node: ixscan1, num: 5}}} +res = db.runCommand({stageDebug: skip1}); +assert(!db.getLastError()); +assert.eq(res.ok, 1); +assert.eq(res.results.length, 16); +assert.eq(res.results[0].foo, 15); +assert.eq(res.results[res.results.length - 1].foo, 0); |