Files
mongo/jstests/core/write/update/update_arraymatch7.js
Jason Zhang 28eb8d299b SERVER-80780 Merge writes without shard key jscore passthrough with existing passthrough suites (#20175)
GitOrigin-RevId: a54cc3a3df44359ea51533f062642ee841f71460
2024-04-08 02:28:42 +00:00

22 lines
574 B
JavaScript

// @tags: [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
let 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();