2009-02-04 18:43:03 -05:00
|
|
|
// Update with mods corner cases.
|
|
|
|
|
|
2009-02-04 18:33:59 -05:00
|
|
|
f = db.jstests_update3;
|
|
|
|
|
|
|
|
|
|
f.drop();
|
2016-03-09 12:17:50 -05:00
|
|
|
f.save({a: 1});
|
|
|
|
|
f.update({}, {$inc: {a: 1}});
|
|
|
|
|
assert.eq(2, f.findOne().a, "A");
|
2009-02-04 18:33:59 -05:00
|
|
|
|
|
|
|
|
f.drop();
|
2016-03-09 12:17:50 -05:00
|
|
|
f.save({a: {b: 1}});
|
|
|
|
|
f.update({}, {$inc: {"a.b": 1}});
|
|
|
|
|
assert.eq(2, f.findOne().a.b, "B");
|
2009-02-04 18:33:59 -05:00
|
|
|
|
|
|
|
|
f.drop();
|
2016-03-09 12:17:50 -05:00
|
|
|
f.save({a: {b: 1}});
|
|
|
|
|
f.update({}, {$set: {"a.b": 5}});
|
|
|
|
|
assert.eq(5, f.findOne().a.b, "C");
|
2009-02-04 18:43:03 -05:00
|
|
|
|
|
|
|
|
f.drop();
|
2016-03-09 12:17:50 -05:00
|
|
|
f.save({'_id': 0});
|
|
|
|
|
f.update({}, {$set: {'_id': 5}});
|
|
|
|
|
assert.eq(0, f.findOne()._id, "D");
|
2013-12-05 14:21:57 -05:00
|
|
|
|
|
|
|
|
f.drop();
|
2016-03-09 12:17:50 -05:00
|
|
|
f.save({_id: 1, a: 1});
|
|
|
|
|
f.update({}, {$unset: {"a": 1, "b.c": 1}});
|
|
|
|
|
assert.docEq(f.findOne(), {_id: 1}, "E");
|