MongoDB\Driver\BulkWrite
PHP Manual

MongoDB\Driver\BulkWrite::delete

(mongodb >=1.0.0)

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

说明

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

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

参数

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

返回值

没有返回值。

错误/异常

范例

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);

?>

参见


MongoDB\Driver\BulkWrite
PHP Manual