2025-02-04 14:03:10 -05:00
|
|
|
const t = db[jsTestName()];
|
2010-03-06 22:12:58 -05:00
|
|
|
t.drop();
|
|
|
|
|
|
2025-08-21 10:17:44 -07:00
|
|
|
let o = {
|
|
|
|
|
_id: 1,
|
|
|
|
|
a: [
|
|
|
|
|
{x: 1, y: 1},
|
|
|
|
|
{x: 2, y: 2},
|
|
|
|
|
{x: 3, y: 3},
|
|
|
|
|
],
|
|
|
|
|
};
|
2025-02-04 14:03:10 -05:00
|
|
|
assert.commandWorked(t.insert(o));
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(o, t.findOne(), "A1");
|
2010-03-06 22:12:58 -05:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
let q = {"a.x": 2};
|
2025-02-04 14:03:10 -05:00
|
|
|
assert.commandWorked(t.update(q, {$set: {b: 5}}));
|
2016-02-04 12:29:01 -05:00
|
|
|
o.b = 5;
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(o, t.findOne(), "A2");
|
2010-03-06 22:12:58 -05:00
|
|
|
|
2025-02-04 14:03:10 -05:00
|
|
|
assert.commandWorked(t.update({"a.x": 2}, {$inc: {"a.$.y": 1}}));
|
2010-03-06 22:12:58 -05:00
|
|
|
o.a[1].y++;
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(o, t.findOne(), "A3");
|