Files
mongo/jstests/core/in2.js
Rishab Joshi 4329ffafa3 SERVER-50442 Remove ensureIndex shell function
This commit replaces all the usages of ensureIndex() with createIndex() in JS tests and JS shell""
2020-11-17 14:23:10 +00:00

31 lines
597 B
JavaScript

t = db.in2;
function go(name, index) {
t.drop();
t.save({a: 1, b: 1});
t.save({a: 1, b: 2});
t.save({a: 1, b: 3});
t.save({a: 1, b: 1});
t.save({a: 2, b: 2});
t.save({a: 3, b: 3});
t.save({a: 1, b: 1});
t.save({a: 2, b: 1});
t.save({a: 3, b: 1});
if (index)
t.createIndex(index);
assert.eq(7, t.find({a: {$in: [1, 2]}}).count(), name + " A");
assert.eq(6, t.find({a: {$in: [1, 2]}, b: {$in: [1, 2]}}).count(), name + " B");
}
go("no index");
go("index on a", {a: 1});
go("index on b", {b: 1});
go("index on a&b", {a: 1, b: 1});