summaryrefslogtreecommitdiff
path: root/jstests/core/find_and_modify_server6588.js
blob: 9c546daba727e3e9573701f4bf11f6a4a46a7420 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

t = db.find_and_modify_sever6588;

initial = {
    _id: 1,
    a: [{b: 1}],
    z: 1
};
up = {
    "$set": {"a.$.b": 2}
};
q = {
    _id: 1,
    "a.b": 1
};
correct = {
    _id: 1,
    a: [{b: 2}],
    z: 1
};

t.drop();
t.insert(initial);
t.update(q, up);
assert.eq(correct, t.findOne());

t.drop();
t.insert(initial);
x = t.findAndModify({query: q, update: up});
assert.eq(correct, t.findOne());

t.drop();
t.insert(initial);
x = t.findAndModify({query: {z: 1, "a.b": 1}, update: up});
assert.eq(correct, t.findOne());