Files
mongo/jstests/core/update_arraymatch7.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
791 B
JavaScript

// Cannot implicitly shard accessed collections because of following errmsg: A single
// update/delete on a sharded collection must contain an exact match on _id or contain the shard
// key.
// @tags: [assumes_unsharded_collection, requires_non_retryable_writes]
// Check that the positional operator works properly when an index only match is used for the update
// query spec. SERVER-5067
t = db.jstests_update_arraymatch7;
t.drop();
function testPositionalInc() {
t.remove({});
t.save({a: [{b: 'match', count: 0}]});
t.update({'a.b': 'match'}, {$inc: {'a.$.count': 1}});
// Check that the positional $inc succeeded.
assert(t.findOne({'a.count': 1}));
}
testPositionalInc();
// Now check with a non multikey index.
t.createIndex({'a.b': 1});
testPositionalInc();