mongodb studio 3T工具 删除字段

db.getCollection("表名").update({"删选条件":{"$exists":true}},{"$unset":{"删除字段名":""}},{multi:true})
# 删除多行 {multi:true} 选择删除单条可以不写
# 通用模板

db.getCollection("表名").update({删选条件},{"$unset":{"删除字段名":""}},{multi:true})

# 举个例子
db.getCollection("user").update({"food":{"$exists":true}},{"$unset":{"food":""}},{multi:true})

注意:查了查大多数的资料显示的都是 {"$unset":{"删除字段名",""}  删除字段名 逗号 连接 空字符串。自己试了试工具会报错。个人亲测 ,由于本篇文章仅限于笔记记录,所以没有测试,逗号 连接是否是为代码化时应用场景,本人使用的工具还是有区别。有任何问题请联系我,我及时改正。

猜你喜欢

转载自blog.csdn.net/weixin_43124425/article/details/114385343