Files
mongo/jstests/core/query/update/update_arraymatch6.js
Steve McClure 1ffbc6c2e9 SERVER-109432: Autofix JS var usage to favor let (#40637)
GitOrigin-RevId: 9674b7db36a0f3f650d39c1e3fb2ad6ff2141cfb
2025-08-28 19:21:01 +00:00

22 lines
452 B
JavaScript

let res;
const t = db[jsTestName()];
t.drop();
function doTest() {
assert.commandWorked(
t.save({
a: [
{id: 1, x: [5, 6, 7]},
{id: 2, x: [8, 9, 10]},
],
}),
);
assert.commandWorked(t.update({"a.id": 1}, {$set: {"a.$.x": [1, 1, 1]}}));
assert.eq(1, t.findOne().a[0].x[0]);
}
doTest();
assert(t.drop());
assert.commandWorked(t.createIndex({"a.id": 1}));
doTest();