Docs Menu

Docs HomePHP Library Manual

MongoDB\Collection::getWriteConcern()

On this page

  • Definition
  • Return Values
  • Example
  • See Also

New in version 1.2.

MongoDB\Collection::getWriteConcern()

Returns the write concern for this collection.

function getWriteConcern(): MongoDB\Driver\WriteConcern

A MongoDB\Driver\WriteConcern object.

<?php
$collection = (new MongoDB\Client)->selectCollection('test', 'users', [
'writeConcern' => new MongoDB\Driver\WriteConcern(1, 0, true),
]);
var_dump($collection->getWriteConcern());

The output would then resemble:

object(MongoDB\Driver\WriteConcern)#5 (2) {
["w"]=>
int(1)
["j"]=>
bool(true)
}
←  MongoDB\Collection::getTypeMap()MongoDB\Collection::insertMany() →