Docs Menu
Docs Home
/ / /
PHP Library Manual
/ /

MongoDB\GridFS\Bucket::getReadPreference()

On this page

  • Definition
  • Return Values
  • Example
  • See Also

New in version 1.2.

MongoDB\GridFS\Bucket::getReadPreference()

Returns the read preference for this GridFS bucket.

function getReadPreference(): MongoDB\Driver\ReadPreference

A MongoDB\Driver\ReadPreference object.

<?php
$database = (new MongoDB\Client)->selectDatabase('test');
$bucket = $database->selectGridFSBucket([
'readPreference' => new MongoDB\Driver\ReadPreference('primaryPreferred'),
]);
var_dump($bucket->getReadPreference());

The output would then resemble:

object(MongoDB\Driver\ReadPreference)#3 (1) {
["mode"]=>
string(16) "primaryPreferred"
}
  • Read Preference in the MongoDB manual

  • MongoDB\Client::getReadPreference()

  • MongoDB\Collection::getReadPreference()

  • MongoDB\Database::getReadPreference()

Back

getReadConcern()