MongoDB\ClientBulkWrite::deleteMany()
2.1版本新增。
定义
MongoDB\ClientBulkWrite::deleteMany()
Specify a delete operation in the bulk write command for all matching documents. This method returns the
MongoDB\ClientBulkWrite
instance on which it's called.function deleteMany( array|object $filter, array $options = [] ): self
参数
$filter
: array|object- 指定要删除的文档的筛选条件。
$options
: array指定所需选项的数组。
错误/异常
MongoDB\Exception\UnsupportedException
,如果所选服务器使用了选项但不支持选项(例如collation
、readConcern
、writeConcern
)。
MongoDB\Exception\InvalidArgumentException
用于与参数或选项解析相关的错误。
MongoDB\Driver\Exception\BulkWriteCommandException for errors related to the write operation. You can inspect the value returned by getWriteErrors() to determine the nature of the error.
MongoDB\ 驱动程序\Exception\RuntimeException 对于扩展级别的其他错误(例如连接错误)。
行为
在评估查询条件时,MongoDB 会根据自己 的 比较规则来BSON types 比较类型和值,这不同于 的PHP 比较 和 类型杂技 规则。匹配特殊BSON类型时,查询条件应使用相应的 BSON类 在扩展(例如使用 MongoDB\ BSON\ObjectId 以匹配 ObjectId )。
If a MongoDB\Driver\Exception\BulkWriteCommandException is thrown, you can call getWriteErrors() and inspect the information in the returned array to determine the nature of the error.
For example, a write operation may have been successfully applied to the primary server but failed to satisfy the write concern. Alternatively, a write operation may have failed outright, for example for violating the unique key constraint.