更新mongo字段

# 更新worker集合的数据,
# upsert 设置为true,表示未匹配到符合条件的数据,则新增
# multi 设置为true,表示匹配到多个符合条件的数据时,更新所有数据;默认false,即只更新符合要求的第一条数据
# key-value,key可以省略引号,value的引号不可以省略。
# update与replaceOne不同,update可以只修改指定的字段,未指定的字段不做任何处理;replaceOne将匹配到的数据完全替换。

db.worker.update({},{$set:{name:"lihui",age:28}},{upsert:false,multi:true})
appearance_type

步骤概述

mongo

>use earth
>show collections
brand
>db.brand.update({},{$set:{uploadBrandPhoto:""}},{upsert:false,multi:true})
//命令中的brand,即第二步查询到的brand

 

posted @ 2023-02-07 16:37  jason47  阅读(136)  评论(0编辑  收藏  举报