-
Notifications
You must be signed in to change notification settings - Fork 260
/
Collection.php
707 lines (614 loc) · 25.9 KB
/
Collection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
<?php
namespace MongoDB;
use MongoDB\Driver\Command;
use MongoDB\Driver\Cursor;
use MongoDB\Driver\Manager;
use MongoDB\Driver\ReadConcern;
use MongoDB\Driver\ReadPreference;
use MongoDB\Driver\Server;
use MongoDB\Driver\WriteConcern;
use MongoDB\Exception\InvalidArgumentException;
use MongoDB\Exception\InvalidArgumentTypeException;
use MongoDB\Exception\UnexpectedTypeException;
use MongoDB\Model\IndexInfoIterator;
use MongoDB\Model\IndexInput;
use MongoDB\Operation\Aggregate;
use MongoDB\Operation\BulkWrite;
use MongoDB\Operation\CreateIndexes;
use MongoDB\Operation\Count;
use MongoDB\Operation\DeleteMany;
use MongoDB\Operation\DeleteOne;
use MongoDB\Operation\Distinct;
use MongoDB\Operation\DropCollection;
use MongoDB\Operation\DropIndexes;
use MongoDB\Operation\Find;
use MongoDB\Operation\FindOne;
use MongoDB\Operation\FindOneAndDelete;
use MongoDB\Operation\FindOneAndReplace;
use MongoDB\Operation\FindOneAndUpdate;
use MongoDB\Operation\InsertMany;
use MongoDB\Operation\InsertOne;
use MongoDB\Operation\ListIndexes;
use MongoDB\Operation\ReplaceOne;
use MongoDB\Operation\UpdateMany;
use MongoDB\Operation\UpdateOne;
use Traversable;
class Collection
{
private static $wireVersionForFindAndModifyWriteConcern = 4;
private $collectionName;
private $databaseName;
private $manager;
private $readConcern;
private $readPreference;
private $typeMap;
private $writeConcern;
/**
* Constructs new Collection instance.
*
* This class provides methods for collection-specific operations, such as
* CRUD (i.e. create, read, update, and delete) and index management.
*
* Supported options:
*
* * readConcern (MongoDB\Driver\ReadConcern): The default read concern to
* use for collection operations. Defaults to the Manager's read concern.
*
* * readPreference (MongoDB\Driver\ReadPreference): The default read
* preference to use for collection operations. Defaults to the Manager's
* read preference.
*
* * typeMap (array): Default type map for cursors and BSON documents.
*
* * writeConcern (MongoDB\Driver\WriteConcern): The default write concern
* to use for collection operations. Defaults to the Manager's write
* concern.
*
* @param Manager $manager Manager instance from the driver
* @param string $namespace Collection namespace (e.g. "db.collection")
* @param array $options Collection options
* @throws InvalidArgumentException
*/
public function __construct(Manager $manager, $namespace, array $options = [])
{
$parts = explode('.', $namespace, 2);
if (count($parts) != 2 || strlen($parts[0]) == 0 || strlen($parts[1]) == 0) {
throw new InvalidArgumentException('$namespace is invalid: ' . $namespace);
}
$this->databaseName = $parts[0];
$this->collectionName = $parts[1];
if (isset($options['readConcern']) && ! $options['readConcern'] instanceof ReadConcern) {
throw new InvalidArgumentTypeException('"readConcern" option', $options['readConcern'], 'MongoDB\Driver\ReadConcern');
}
if (isset($options['readPreference']) && ! $options['readPreference'] instanceof ReadPreference) {
throw new InvalidArgumentTypeException('"readPreference" option', $options['readPreference'], 'MongoDB\Driver\ReadPreference');
}
if (isset($options['typeMap']) && ! is_array($options['typeMap'])) {
throw new InvalidArgumentTypeException('"typeMap" option', $options['typeMap'], 'array');
}
if (isset($options['writeConcern']) && ! $options['writeConcern'] instanceof WriteConcern) {
throw new InvalidArgumentTypeException('"writeConcern" option', $options['writeConcern'], 'MongoDB\Driver\WriteConcern');
}
$this->manager = $manager;
$this->readConcern = isset($options['readConcern']) ? $options['readConcern'] : $this->manager->getReadConcern();
$this->readPreference = isset($options['readPreference']) ? $options['readPreference'] : $this->manager->getReadPreference();
$this->typeMap = isset($options['typeMap']) ? $options['typeMap'] : null;
$this->writeConcern = isset($options['writeConcern']) ? $options['writeConcern'] : $this->manager->getWriteConcern();
}
/**
* Return internal properties for debugging purposes.
*
* @see http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.debuginfo
* @param array
*/
public function __debugInfo()
{
return [
'collectionName' => $this->collectionName,
'databaseName' => $this->databaseName,
'manager' => $this->manager,
'readConcern' => $this->readConcern,
'readPreference' => $this->readPreference,
'typeMap' => $this->typeMap,
'writeConcern' => $this->writeConcern,
];
}
/**
* Return the collection namespace (e.g. "db.collection").
*
* @param string
*/
public function __toString()
{
return $this->databaseName . '.' . $this->collectionName;
}
/**
* Executes an aggregation framework pipeline on the collection.
*
* Note: this method's return value depends on the MongoDB server version
* and the "useCursor" option. If "useCursor" is true, a Cursor will be
* returned; otherwise, an ArrayIterator is returned, which wraps the
* "result" array from the command response document.
*
* Note: BSON deserialization of inline aggregation results (i.e. not using
* a command cursor) does not yet support a custom type map
* (depends on: https://jira.mongodb.org/browse/PHPC-314).
*
* @see Aggregate::__construct() for supported options
* @param array $pipeline List of pipeline operations
* @param array $options Command options
* @return Traversable
*/
public function aggregate(array $pipeline, array $options = [])
{
$hasOutStage = \MongoDB\is_last_pipeline_operator_out($pipeline);
/* A "majority" read concern is not compatible with the $out stage, so
* avoid providing the Collection's read concern if it would conflict.
*/
if ( ! isset($options['readConcern']) && ! ($hasOutStage && $this->readConcern->getLevel() === ReadConcern::MAJORITY)) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
if ($hasOutStage) {
$options['readPreference'] = new ReadPreference(ReadPreference::RP_PRIMARY);
}
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new Aggregate($this->databaseName, $this->collectionName, $pipeline, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Executes multiple write operations.
*
* @see BulkWrite::__construct() for supported options
* @param array[] $operations List of write operations
* @param array $options Command options
* @return BulkWriteResult
*/
public function bulkWrite(array $operations, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new BulkWrite($this->databaseName, $this->collectionName, $operations, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Gets the number of documents matching the filter.
*
* @see Count::__construct() for supported options
* @param array|object $filter Query by which to filter documents
* @param array $options Command options
* @return integer
*/
public function count($filter = [], array $options = [])
{
if ( ! isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
$operation = new Count($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Create a single index for the collection.
*
* @see Collection::createIndexes()
* @param array|object $key Document containing fields mapped to values,
* which denote order or an index type
* @param array $options Index options
* @return string The name of the created index
*/
public function createIndex($key, array $options = [])
{
return current($this->createIndexes([['key' => $key] + $options]));
}
/**
* Create one or more indexes for the collection.
*
* Each element in the $indexes array must have a "key" document, which
* contains fields mapped to an order or type. Other options may follow.
* For example:
*
* $indexes = [
* // Create a unique index on the "username" field
* [ 'key' => [ 'username' => 1 ], 'unique' => true ],
* // Create a 2dsphere index on the "loc" field with a custom name
* [ 'key' => [ 'loc' => '2dsphere' ], 'name' => 'geo' ],
* ];
*
* If the "name" option is unspecified, a name will be generated from the
* "key" document.
*
* @see http://docs.mongodb.org/manual/reference/command/createIndexes/
* @see http://docs.mongodb.org/manual/reference/method/db.collection.createIndex/
* @param array[] $indexes List of index specifications
* @return string[] The names of the created indexes
* @throws InvalidArgumentException if an index specification is invalid
*/
public function createIndexes(array $indexes)
{
$operation = new CreateIndexes($this->databaseName, $this->collectionName, $indexes);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Deletes all documents matching the filter.
*
* @see DeleteMany::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/delete/
* @param array|object $filter Query by which to delete documents
* @param array $options Command options
* @return DeleteResult
*/
public function deleteMany($filter, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new DeleteMany($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Deletes at most one document matching the filter.
*
* @see DeleteOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/delete/
* @param array|object $filter Query by which to delete documents
* @param array $options Command options
* @return DeleteResult
*/
public function deleteOne($filter, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new DeleteOne($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Finds the distinct values for a specified field across the collection.
*
* @see Distinct::__construct() for supported options
* @param string $fieldName Field for which to return distinct values
* @param array|object $filter Query by which to filter documents
* @param array $options Command options
* @return mixed[]
*/
public function distinct($fieldName, $filter = [], array $options = [])
{
if ( ! isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
$operation = new Distinct($this->databaseName, $this->collectionName, $fieldName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Drop this collection.
*
* @return object Command result document
*/
public function drop()
{
$operation = new DropCollection($this->databaseName, $this->collectionName);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Drop a single index in the collection.
*
* @param string $indexName Index name
* @return object Command result document
* @throws InvalidArgumentException if $indexName is an empty string or "*"
*/
public function dropIndex($indexName)
{
$indexName = (string) $indexName;
if ($indexName === '*') {
throw new InvalidArgumentException('dropIndexes() must be used to drop multiple indexes');
}
$operation = new DropIndexes($this->databaseName, $this->collectionName, $indexName);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Drop all indexes in the collection.
*
* @return object Command result document
*/
public function dropIndexes()
{
$operation = new DropIndexes($this->databaseName, $this->collectionName, '*');
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Finds documents matching the query.
*
* @see Find::__construct() for supported options
* @see http://docs.mongodb.org/manual/core/read-operations-introduction/
* @param array|object $filter Query by which to filter documents
* @param array $options Additional options
* @return Cursor
*/
public function find($filter = [], array $options = [])
{
if ( ! isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new Find($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Finds a single document matching the query.
*
* @see FindOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/core/read-operations-introduction/
* @param array|object $filter Query by which to filter documents
* @param array $options Additional options
* @return object|null
*/
public function findOne($filter = [], array $options = [])
{
if ( ! isset($options['readConcern'])) {
$options['readConcern'] = $this->readConcern;
}
if ( ! isset($options['readPreference'])) {
$options['readPreference'] = $this->readPreference;
}
if ( ! isset($options['typeMap'])) {
$options['typeMap'] = $this->typeMap;
}
$operation = new FindOne($this->databaseName, $this->collectionName, $filter, $options);
$server = $this->manager->selectServer($options['readPreference']);
return $operation->execute($server);
}
/**
* Finds a single document and deletes it, returning the original.
*
* The document to return may be null.
*
* Note: BSON deserialization of the returned document does not yet support
* a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
*
* @see FindOneAndDelete::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
* @param array|object $filter Query by which to filter documents
* @param array $options Command options
* @return object|null
*/
public function findOneAndDelete($filter, array $options = [])
{
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForFindAndModifyWriteConcern)) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new FindOneAndDelete($this->databaseName, $this->collectionName, $filter, $options);
return $operation->execute($server);
}
/**
* Finds a single document and replaces it, returning either the original or
* the replaced document.
*
* The document to return may be null. By default, the original document is
* returned. Specify FindOneAndReplace::RETURN_DOCUMENT_AFTER for the
* "returnDocument" option to return the updated document.
*
* Note: BSON deserialization of the returned document does not yet support
* a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
*
* @see FindOneAndReplace::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
* @param array|object $filter Query by which to filter documents
* @param array|object $replacement Replacement document
* @param array $options Command options
* @return object|null
*/
public function findOneAndReplace($filter, $replacement, array $options = [])
{
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForFindAndModifyWriteConcern)) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new FindOneAndReplace($this->databaseName, $this->collectionName, $filter, $replacement, $options);
return $operation->execute($server);
}
/**
* Finds a single document and updates it, returning either the original or
* the updated document.
*
* The document to return may be null. By default, the original document is
* returned. Specify FindOneAndUpdate::RETURN_DOCUMENT_AFTER for the
* "returnDocument" option to return the updated document.
*
* Note: BSON deserialization of the returned document does not yet support
* a custom type map (depends on: https://jira.mongodb.org/browse/PHPC-314).
*
* @see FindOneAndReplace::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/findAndModify/
* @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched document
* @param array $options Command options
* @return object|null
*/
public function findOneAndUpdate($filter, $update, array $options = [])
{
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
if ( ! isset($options['writeConcern']) && \MongoDB\server_supports_feature($server, self::$wireVersionForFindAndModifyWriteConcern)) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new FindOneAndUpdate($this->databaseName, $this->collectionName, $filter, $update, $options);
return $operation->execute($server);
}
/**
* Return the collection name.
*
* @return string
*/
public function getCollectionName()
{
return $this->collectionName;
}
/**
* Return the database name.
*
* @return string
*/
public function getDatabaseName()
{
return $this->databaseName;
}
/**
* Return the collection namespace.
*
* @see http://docs.mongodb.org/manual/faq/developers/#faq-dev-namespace
* @return string
*/
public function getNamespace()
{
return $this->databaseName . '.' . $this->collectionName;
}
/**
* Inserts multiple documents.
*
* @see InsertMany::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/insert/
* @param array[]|object[] $documents The documents to insert
* @param array $options Command options
* @return InsertManyResult
*/
public function insertMany(array $documents, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new InsertMany($this->databaseName, $this->collectionName, $documents, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Inserts one document.
*
* @see InsertOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/insert/
* @param array|object $document The document to insert
* @param array $options Command options
* @return InsertOneResult
*/
public function insertOne($document, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new InsertOne($this->databaseName, $this->collectionName, $document, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Returns information for all indexes for the collection.
*
* @see ListIndexes::__construct() for supported options
* @return IndexInfoIterator
*/
public function listIndexes(array $options = [])
{
$operation = new ListIndexes($this->databaseName, $this->collectionName, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Replaces at most one document matching the filter.
*
* @see ReplaceOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/update/
* @param array|object $filter Query by which to filter documents
* @param array|object $replacement Replacement document
* @param array $options Command options
* @return UpdateResult
*/
public function replaceOne($filter, $replacement, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new ReplaceOne($this->databaseName, $this->collectionName, $filter, $replacement, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Updates all documents matching the filter.
*
* @see UpdateMany::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/update/
* @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched documents
* @param array $options Command options
* @return UpdateResult
*/
public function updateMany($filter, $update, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new UpdateMany($this->databaseName, $this->collectionName, $filter, $update, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Updates at most one document matching the filter.
*
* @see ReplaceOne::__construct() for supported options
* @see http://docs.mongodb.org/manual/reference/command/update/
* @param array|object $filter Query by which to filter documents
* @param array|object $update Update to apply to the matched document
* @param array $options Command options
* @return UpdateResult
*/
public function updateOne($filter, $update, array $options = [])
{
if ( ! isset($options['writeConcern'])) {
$options['writeConcern'] = $this->writeConcern;
}
$operation = new UpdateOne($this->databaseName, $this->collectionName, $filter, $update, $options);
$server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
return $operation->execute($server);
}
/**
* Get a clone of this collection with different options.
*
* @see Collection::__construct() for supported options
* @param array $options Collection constructor options
* @return Collection
*/
public function withOptions(array $options = [])
{
$options += [
'readConcern' => $this->readConcern,
'readPreference' => $this->readPreference,
'typeMap' => $this->typeMap,
'writeConcern' => $this->writeConcern,
];
return new Collection($this->manager, $this->databaseName . '.' . $this->collectionName, $options);
}
}