MongoDB 批量更新和删除字段
MongoDB 大约 401 字批量更新
db.getCollection('order').update(
{account_id:'abcd'},
{$set:{account_id:'edgh'}},
{multi:true}
)
删除字段
$unset
表示删除指定指端,可以是1
或者0
或者true
。
db.getCollection('order').update(
{account_id:'abcd'},
{$unset:{account_id:1}},
{multi:true}
)
注意
下面语句会将整条记录替换为只保留了account_id
和主键_id
。慎用。
db.getCollection('order').update(
{account_id:'abcd'},
{account_id:'edgh'},
{multi:true}
)
阅读 2874 · 发布于 2020-11-20
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb扫描下方二维码关注公众号和小程序↓↓↓

昵称:
随便看看
换一批
-
Java 并发编程之 happens-before 7 条规则阅读 981
-
Android 使用 CountDownTimer 类进行倒计时阅读 1440
-
Android ActivityManager阅读 2953
-
Golang 数字转字符串阅读 1028
-
JavaScript 空值合并操作符 ??阅读 983
-
软考-系统架构设计师:Flynn 分类法阅读 2407
-
JVM:运行时方法区之常量池阅读 533
-
Android ContentProvider 提供 Assets 目录下的图片或文件阅读 1935
-
Windows10 关闭子系统提示音阅读 457
-
Docker 使用 dfimage 从镜像中提取 Dockerfile阅读 296