mongodb 修改字段

//修改字段名称,把synonymsList表的name_status修改为status

db.getCollection('synonymsList').update({}, {$rename : {"name_status" : "status"}}, false, true)

//把 from这个数组有hengduan这个值,并且zhLatin是空的数据的zhLatin字段删除

db.getCollection('species').update({"from":"hengduan","zhLatin":null},{$unset:{'zhLatin':''}},false, true)

db.collection.update(criteria,objNew,upsert,multi)

参数说明:

criteria:查询条件

objNew:update对象和一些更新操作符

upsert:如果不存在update的记录,是否插入objNew这个新的文档,true为插入,默认为false,不插入。

multi:默认是false,只更新找到的第一条记录。如果为true,把按条件查询出来的记录全部更新。

猜你喜欢

转载自www.cnblogs.com/CHWLearningNotes/p/9141483.html
今日推荐