Files
mongo/jstests/core/unset.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
580 B
JavaScript

t = db.unset;
t.drop();
orig = { _id : 1, emb : {} };
t.insert(orig);
t.update( { _id : 1 }, { $unset : { 'emb.a' : 1 }});
t.update( { _id : 1 }, { $unset : { 'z' : 1 }});
assert.eq( orig , t.findOne() , "A" );
t.update( { _id : 1 }, { $set : { 'emb.a' : 1 }});
t.update( { _id : 1 }, { $set : { 'z' : 1 }});
t.update( { _id : 1 }, { $unset : { 'emb.a' : 1 }});
t.update( { _id : 1 }, { $unset : { 'z' : 1 }});
assert.eq( orig , t.findOne() , "B" ); // note that emb isn't removed
t.update( { _id : 1 }, { $unset : { 'emb' : 1 }});
assert.eq( {_id :1} , t.findOne() , "C" );