当前位置:数据库 > DB2 >>

mongodb Modifiers(原子操作)

mongodb Modifiers(原子操作)
 
Modifiers(原子操作)
 
$set:{ $set : { field : value } }
 
$unset :删除,{ $unset : { field : 1} }
 
$inc :{ $inc : { field : value } }
 
$push
 
$pushAll :{ $pushAll : { field : value_array } }
 
$pull:{ $pull : { field : _value } }
 
$pullAll :
 
$addToSet:不存在则添加。
 
$pop:删除数组的第一个或最后一个元素。{ $pop : { field : 1 } }
 
$rename:{ $rename : { old_field_name : new_field_name } }
 
$bit – 位操作,integer类型。{$bit : { field : {and : 5}}}
 
$ 偏移操作符:
 
> t.find() { "_id" : ObjectId("4b97e62bf1d8c7152c9ccb74"), "title" : "ABC", "comments" : [ { "by" : "joe", "votes" : 3 }, { "by" : "jane", "votes" : 7 } ] }
 
> t.update( {'comments.by':'joe'}, {$inc:{'comments.$.votes':1}}, false, true )
 
> t.find() { "_id" : ObjectId("4b97e62bf1d8c7152c9ccb74"), "title" : "ABC", "comments" : [ { "by" : "joe", "votes" : 4 }, { "by" : "jane", "votes" : 7 } ] }
 
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,