Commit 0bb64620 authored by Andreas Braun's avatar Andreas Braun Committed by Jeremy Mikola

Add accessor for gridFS buckets in database class

parent 0195906b
...@@ -9,6 +9,7 @@ use MongoDB\Driver\ReadConcern; ...@@ -9,6 +9,7 @@ use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference; use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\WriteConcern; use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\InvalidArgumentException; use MongoDB\Exception\InvalidArgumentException;
use MongoDB\GridFS\Bucket;
use MongoDB\Model\CollectionInfoIterator; use MongoDB\Model\CollectionInfoIterator;
use MongoDB\Operation\CreateCollection; use MongoDB\Operation\CreateCollection;
use MongoDB\Operation\DatabaseCommand; use MongoDB\Operation\DatabaseCommand;
...@@ -262,6 +263,26 @@ class Database ...@@ -262,6 +263,26 @@ class Database
return new Collection($this->manager, $this->databaseName, $collectionName, $options); return new Collection($this->manager, $this->databaseName, $collectionName, $options);
} }
/**
* Select a GridFS bucket within this database.
*
* @see Bucket::__construct() for supported options
* @param string $bucketName Name of the bucket to select (defaults to 'fs')
* @param array $options Bucket constructor options
* @return Bucket
*/
public function selectGridFSBucket($bucketName = 'fs', array $options = [])
{
$options += [
'bucketName' => $bucketName,
'readConcern' => $this->readConcern,
'readPreference' => $this->readPreference,
'writeConcern' => $this->writeConcern,
];
return new Bucket($this->manager, $this->databaseName, $options);
}
/** /**
* Get a clone of this database with different options. * Get a clone of this database with different options.
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment