工具:Robo
添加Covertotal字段

查看添加完后的数据

参数说明:
query : update的查询条件,类似sql update查询内where后面的。
update : update的对象和一些更新的操作符(如inc...)等,也可以理解为sql update查询内set后面的
upsert : 可选,这个参数的意思是,如果不存在update的记录,是否插入objNew,true为插入,默认是false,不插入。
multi : 可选,mongodb 默认是false,只更新找到的第一条记录,如果这个参数为true,就把按条件查出来多条记录全部更新。
writeConcern :可选,抛出异常的级别。
1 、添加一个字段. table 代表表名 , 添加字段 content,字符串类型
db.table.update({}, {$set: {covertotal:""}}, {multi: true})
2、删除一个字段
db.table.update({},{$unset:{covertotal:""}},false, true)
网友评论