What's the difference between the two commands here?
db.collection.deleteMany({condition})
db.collection.remove({condition})

推荐答案

据我所知,

db.收集删除许多

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

REF: db.收集删除许多

在哪里

db.收集go 除

return WriteResult

And to remove a single document, there a similar command, db.收集go 除One where as with db.收集go 除 you need to set and option called justOne option to limit delete to 1 document.

否则我猜他们是相似的.

node .js驱动程序

When talking about node .js驱动程序, remove has been deprecated (and may be removed in future releases) and deleteOne or deleteMany.

希望这有意义....

Mongodb相关问答推荐

MongoDB$unionWith,如何 Select 特定文档

MongoDB合并按键更新值的对象数组

如何在MongoDB中使用Aggregation来计算两个键相同但字段不同的对象数组的总值,并将其合并为一个?

获取文档字段名并将其作为嵌套字段添加到聚合中

在MongoDB集合中按文档内的频率对数组排序

执行聚合以消除重复并获得唯一计数

如何获取键值对的对象,其中值仅具有 mongoDB 中的投影字段

MongoDB - 将数组元素转换为新字段

Mongo,通过 Lookup 计算多个文档中数组中的项目

如何使用sailsjs v0.10连接mongodb?

在 GridFS、express、mongoDB、node.js 中存储来自 POST 请求的数据流

ZonedDateTime 与 MongoDB

使用 MongoDB 进行嵌套分组

TypeError: object of type 'Cursor' has no len()

在MongoDB中查询一个半​​径内的位置

在安装的 MongoDB homebrew 中设置 dbpath (Mac OS)

如何通过mongoose更新 mongodb 中的对象?

如何在 Ubuntu 上安装 mongodb-clients 最新版本?

有没有办法防止 MongoDB 向集合名称添加复数形式?

即使重新安装后,Mongo 仍在等待 27017