Files
mongo/jstests/core/inc2.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

25 lines
435 B
JavaScript

t = db.inc2;
t.drop();
t.save({_id: 1, x: 1});
t.save({_id: 2, x: 2});
t.save({_id: 3, x: 3});
function order() {
return t.find().sort({x: 1}).map(function(z) {
return z._id;
});
}
assert.eq("1,2,3", order(), "A");
t.update({_id: 1}, {$inc: {x: 4}});
assert.eq("2,3,1", order(), "B");
t.createIndex({x: 1});
assert.eq("2,3,1", order(), "C");
t.update({_id: 3}, {$inc: {x: 4}});
assert.eq("2,1,3", order(), "D");