MongoDB\Driver\BulkWrite
PHP Manual

MongoDB\Driver\BulkWrite::delete

(mongodb >=1.0.0)

MongoDB\Driver\BulkWrite::deleteAdd a delete operation to the bulk

Description

public void MongoDB\Driver\BulkWrite::delete ( array|object $filter [, array $deleteOptions ] )

Adds a delete operation to the MongoDB\Driver\BulkWrite.

Parameters

filter (array|object)

The search filter.

deleteOptions

deleteOptions
Option Type Description Default
limit bool Delete all matching documents (limit=0), or only the first matching document (limit=1) FALSE

Return Values

No value is returned.

Errors/Exceptions

Examples

Example #1 MongoDB\Driver\BulkWrite::delete() example

<?php

$bulk 
= new MongoDB\Driver\BulkWrite;
$bulk->delete(['x' => 1], ['limit' => 1]);
$bulk->delete(['x' => 2], ['limit' => 0]);

$manager = new MongoDB\Driver\Manager('mongodb://localhost:27017');
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY1000);
$result $manager->executeBulkWrite('db.collection'$bulk$writeConcern);

?>

See Also


MongoDB\Driver\BulkWrite
PHP Manual