这两个命令有什么区别?
db.collection.deleteMany({condition})
db.collection.remove({condition})
Dav*_*mit 23
据我所知,
db.collection.deleteMany
Returns:
A document containing:
> A boolean acknowledged as true if the operation ran with write concern or false if write concern was disabled
> deletedCount containing the number of deleted documents
Run Code Online (Sandbox Code Playgroud)
在哪里
db.collection.remove
并且要删除单个文档,还有一个类似的命令,db.collection.removeOne其中db.collection.remove需要设置和选项调用justOne选项来限制删除到1个文档.
否则我猜他们是相似的.
node.js驱动程序
在谈论时node.js drivers,remove已被弃用(可能在将来的版本中被删除)和deleteOne或deleteMany.
希望这是有道理的....
Rev*_*l89 17
他们做同样的事情.不同之处在于返回的值.
用remove():
> db.ticker.remove({"name": "Bitcoin"})
WriteResult({ "nRemoved" : 2 })
Run Code Online (Sandbox Code Playgroud)
用deleteMany():
> db.ticker.deleteMany({"name": "Bitcoin"})
{ "acknowledged" : true, "deletedCount" : 2 }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20034 次 |
| 最近记录: |