|
9 | 9 | use MongoDB\Driver\ReadPreference;
|
10 | 10 | use MongoDB\Driver\WriteConcern;
|
11 | 11 | use MongoDB\Exception\InvalidArgumentException;
|
| 12 | +use MongoDB\GridFS\Bucket; |
12 | 13 | use MongoDB\Model\CollectionInfoIterator;
|
13 | 14 | use MongoDB\Operation\CreateCollection;
|
14 | 15 | use MongoDB\Operation\DatabaseCommand;
|
@@ -262,6 +263,26 @@ public function selectCollection($collectionName, array $options = [])
|
262 | 263 | return new Collection($this->manager, $this->databaseName, $collectionName, $options);
|
263 | 264 | }
|
264 | 265 |
|
| 266 | + /** |
| 267 | + * Select a GridFS bucket within this database. |
| 268 | + * |
| 269 | + * @see Bucket::__construct() for supported options |
| 270 | + * @param string $bucketName Name of the bucket to select (defaults to 'fs') |
| 271 | + * @param array $options Bucket constructor options |
| 272 | + * @return Bucket |
| 273 | + */ |
| 274 | + public function selectGridFSBucket($bucketName = 'fs', array $options = []) |
| 275 | + { |
| 276 | + $options += [ |
| 277 | + 'bucketName' => $bucketName, |
| 278 | + 'readConcern' => $this->readConcern, |
| 279 | + 'readPreference' => $this->readPreference, |
| 280 | + 'writeConcern' => $this->writeConcern, |
| 281 | + ]; |
| 282 | + |
| 283 | + return new Bucket($this->manager, $this->databaseName, $options); |
| 284 | + } |
| 285 | + |
265 | 286 | /**
|
266 | 287 | * Get a clone of this database with different options.
|
267 | 288 | *
|
|
0 commit comments