Files
mongo/jstests/core/update3.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

28 lines
598 B
JavaScript

// Update with mods corner cases.
f = db.jstests_update3;
f.drop();
f.save( { a:1 } );
f.update( {}, {$inc:{ a:1 }} );
assert.eq( 2, f.findOne().a , "A" );
f.drop();
f.save( { a:{ b: 1 } } );
f.update( {}, {$inc:{ "a.b":1 }} );
assert.eq( 2, f.findOne().a.b , "B" );
f.drop();
f.save( { a:{ b: 1 } } );
f.update( {}, {$set:{ "a.b":5 }} );
assert.eq( 5, f.findOne().a.b , "C" );
f.drop();
f.save( {'_id':0} );
f.update( {}, {$set:{'_id':5}} );
assert.eq( 0, f.findOne()._id , "D" );
f.drop();
f.save({_id:1, a:1})
f.update({}, {$unset:{"a":1, "b.c":1}})
assert.docEq(f.findOne(), {_id:1}, "E")