Files
mongo/jstests/core/update_arraymatch7.js
Siyuan Zhou 3660343e0b SERVER-12127 migrate js tests to jscore suite when not related to writes
Migrate js tests starting from j-z.
Include SERVER-12920 Update use_power_of_2.js

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
2014-03-03 22:54:10 -05:00

20 lines
547 B
JavaScript

// 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();