php8.5
Home/ Manual/ driver / bulkwritecommand/ MongoDB\Driver\BulkWriteCommand::deleteMany

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

options
OptionTypeDescriptionDefault
hintstring|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::deleteOne
  • MongoDB\Driver\Manager::executeBulkWriteCommand
  • MongoDB\Driver\BulkWriteCommandResult

Source: reference/mongodb/mongodb/driver/bulkwritecommand/deletemany.xml · from the official PHP manual (php/doc-en)