博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【MonogoDB】The high update operation of MongoDB
阅读量:4170 次
发布时间:2019-05-26

本文共 1142 字,大约阅读时间需要 3 分钟。

In the last four blog, we talked about the high query operation of mongodb. Now in this blog let's know about the high update operation about monodb.

1. Save

as for save(), whose function is to update the existing record and to create the new record.
grammar: db.mycollection.save(x);

2. General Operation

2.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 will support all the type. 

2.3 $push, $pushAll,$addToSet

{ $push : { field : value }  } 
function: if the field is a existing arry, this function will add the value to the end.  if filed doesnot exist, it will add the new field, and then set the field value.  if field do exists but not array, it will throw error. 
$pushAll:  { $pushAll : {field : value_array } } 
this function is the same as $push, but 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}}
你可能感兴趣的文章
用python的matplotlib和numpy库绘制股票K线均线
查看>>
以互联网公司的经验告诉大家,架构师究竟比高级开发厉害在哪?
查看>>
GanttProject 使用的控件第三方包:jdnc-modifBen.jar
查看>>
ps、grep和kill联合使用杀掉进程
查看>>
openfire中的mina框架使用
查看>>
去掉Windows Messager的自动登录
查看>>
dspace可以检索中文了
查看>>
利用Eclipse编辑中文资源,配置文件
查看>>
将中文转为unicode 及转回中文函数
查看>>
《程序员》专访金蝶:是谁不相信国产软件?
查看>>
debian的gnome下的xmms乱码解决方案
查看>>
python切片操作
查看>>
python 中的split()函数和os.path.split()函数
查看>>
python 矩阵转置
查看>>
python 使用zip合并相邻的列表项
查看>>
python iter( )函数
查看>>
Python 迭代器(iterator)
查看>>
Python enumerate类
查看>>
leetcode 99 Recover Binary Search Tree (python)
查看>>
linux echo 向文件中追加信息
查看>>