Files
mongo/jstests/core/write/update/update_arraymatch1.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

16 lines
335 B
JavaScript

let t = db.update_arraymatch1;
t.drop();
let o = {_id: 1, a: [{x: 1, y: 1}, {x: 2, y: 2}, {x: 3, y: 3}]};
t.insert(o);
assert.eq(o, t.findOne(), "A1");
let q = {"a.x": 2};
t.update(q, {$set: {b: 5}});
o.b = 5;
assert.eq(o, t.findOne(), "A2");
t.update({"a.x": 2}, {$inc: {"a.$.y": 1}});
o.a[1].y++;
assert.eq(o, t.findOne(), "A3");