Add an update operation to the bulk


(mongodb >=0.2.0)

MongoDB\Driver\BulkWrite::updateAdd an update operation to the bulk

Описание

public void MongoDB\Driver\BulkWrite::update ( array|object $filter , array|object $newObj [, array $updateOptions ] )

Список параметров

filter

The search filter.

newObj

Either an array of update operators, or the full object to be replaced with

updateOptions

updateOptions
Option Type Description Default
limit boolean Update only the first matching document (limit=1), or all matching documents (limit=0) 1
upsert boolean If filter does not match an existing document, insert the newObj as a new object, applying any atomic modifiers to the filter if applicable. 0

Возвращаемые значения

Эта функция не возвращает значения после выполнения.

Ошибки

  • Throws MongoDB\Driver\InvalidArgumentException on argument parsing errors.

Примеры

Пример #1 MongoDB\Driver\BulkWrite::update() example

<?php

$bulk 
= new MongoDB\Driver\BulkWrite(true);
$bulk->update(array("tag" => "mongodb"), array("limit" => 1));
$bulk->update(array(  "x" => "2"     ), array("y" => 3'$set' => array("z" => 4)), array("upsert" => 0));

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

?>

Смотрите также