summaryrefslogtreecommitdiff
path: root/jstests/update_arraymatch7.js
blob: 5621f60c39edf946a06fd325bba1f8ec34482a2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Check that the positional operator works properly when an index only match is used for the update
// query spec.  SERVER-5067

t = db.jstests_update_arraymatch7;
t.drop();

function testPositionalInc() {
    t.remove({});
    t.save( { a:[ { b:'match', count:0 } ] } );
    t.update( { 'a.b':'match' }, { $inc:{ 'a.$.count':1 } } );
    // Check that the positional $inc succeeded.
    assert( t.findOne( { 'a.count':1 } ) );
}

testPositionalInc();

// Now check with a non multikey index.
t.ensureIndex( { 'a.b' : 1 } );
testPositionalInc();