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

23 lines
468 B
JavaScript

let t = db.updated;
t.drop();
let o = {_id: Math.random(), items: [null, null, null, null]};
t.insert(o);
assert.docEq(o, t.findOne(), "A1");
o.items[0] = {
amount: 9000,
itemId: 1
};
t.update({}, {$set: {"items.0": o.items[0]}});
assert.docEq(o, t.findOne(), "A2");
o.items[0].amount += 1000;
o.items[1] = {
amount: 1,
itemId: 2
};
t.update({}, {$inc: {"items.0.amount": 1000}, $set: {"items.1": o.items[1]}});
assert.docEq(o, t.findOne(), "A3");