The last four blogs, we talked about the high query operation of MongoDB. Now on this blog let's know about the high update operation about MONODB.
1. Saveas for Save (), whose function was to update the existing record and to create the new record.
Grammar:db.mycollection.save (x);
2. General Operation2.1 $inc Grammar: {$inc: {Field:value}}
Function:add the value to the certain field.
Example
2.2 $Set and $unset {$set: {Field:value}}/{$unset: {field:1}}
Function:set the field value, if the field does not exist, then add the new field, and value would support all the type.
2.3 $push, $pushAll, $addToSet {$push: {Field:value}}
Function:if The field is a existing Arry, this function would add the value to the end. If filed doesnot exist, it'll add the new field, and then set the field value. If field does exists but is not an array, it would throw the error.
$pushAll: {$pushAll: {Field:value_array}}
This function is the same as $push and only the Value_array is array.
$addToSet: {$addToSet: {Field:value}}
2.4 $pop and $pull $pullAll
2.5 $rename {$rename: {old_friend_name:new_field_name}}
"Monogodb" The high update operation of MongoDB