summaryrefslogtreecommitdiff
path: root/jstests/core/update_multi5.js
blob: e610462a620933a25987f4fae186152b98f4f91a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// tests that $addToSet works in a multi-update.
(function() {
    "use strict";
    var t = db.update_multi5;
    t.drop();

    assert.writeOK(t.insert({path: 'r1', subscribers: [1, 2]}));
    assert.writeOK(t.insert({path: 'r2', subscribers: [3, 4]}));

    var res = assert.writeOK(t.update(
        {}, {$addToSet: {subscribers: 5}}, {upsert: false, multi: true, writeConcern: {w: 1}}));

    assert.eq(res.nMatched, 2, tojson(res));

    t.find().forEach(function(z) {
        assert.eq(3, z.subscribers.length, tojson(z));
    });
})();