MongoDB\Driver\BulkWriteCommand::deleteMany
PHP function
Edit on GitHub ✎
(mongodb >=2.1.0)
Add a deleteMany operation
Description
MongoDB\Driver\BulkWriteCommand::deleteMany(string $namespace, array|object $filter, array|null $options = null): void
Add a deleteMany operation to the MongoDB\Driver\BulkWriteCommand. All documents matching filter in the collection identified by namespace will be deleted.
Parameters
optionsOption Type Description Default hint string|array|objectIndex specification. Specify either the index name as a string or the index key pattern. If specified, then the query system will only consider plans using the hinted index.
Return Values
Void
Errors/Exceptions
Examples
MongoDB\Driver\BulkWriteCommand::deleteMany() example
php
<?php
$manager = new MongoDB\Driver\Manager;
$bulk = new MongoDB\Driver\BulkWriteCommand;
$bulk->deleteMany('db.coll', ['x' => ['$gt' => 1]]);
$result = $manager->executeBulkWriteCommand($bulk);
?>See Also
MongoDB\Driver\BulkWriteCommand::deleteOneMongoDB\Driver\Manager::executeBulkWriteCommandMongoDB\Driver\BulkWriteCommandResult