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

19 lines
453 B
JavaScript

// Sparse indexes with arrays SERVER-3216
t = db.jstests_indext;
t.drop();
t.createIndex({'a.b': 1}, {sparse: true});
t.save({a: []});
t.save({a: 1});
assert.eq(0, t.find().hint({'a.b': 1}).itcount());
t.createIndex({'a.b': 1, 'a.c': 1}, {sparse: true});
t.save({a: []});
t.save({a: 1});
assert.eq(0, t.find().hint({'a.b': 1, 'a.c': 1}).itcount());
t.save({a: [{b: 1}]});
t.save({a: 1});
assert.eq(1, t.find().hint({'a.b': 1, 'a.c': 1}).itcount());