@@ -263,9 +263,8 @@ public function bulkWrite(array $operations, array $options = [])
263
263
);
264
264
265
265
$ operation = new BulkWrite ($ this ->databaseName , $ this ->collectionName , $ operations , $ options );
266
- $ server = select_server ($ this ->manager , $ options );
267
266
268
- return $ operation ->execute ($ server );
267
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
269
268
}
270
269
271
270
/**
@@ -286,11 +285,9 @@ public function count($filter = [], array $options = [])
286
285
{
287
286
$ options = $ this ->inheritReadOptions ($ options );
288
287
289
- $ server = select_server ($ this ->manager , $ options );
290
-
291
288
$ operation = new Count ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
292
289
293
- return $ operation ->execute ($ server );
290
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
294
291
}
295
292
296
293
/**
@@ -309,11 +306,9 @@ public function countDocuments($filter = [], array $options = [])
309
306
{
310
307
$ options = $ this ->inheritReadOptions ($ options );
311
308
312
- $ server = select_server ($ this ->manager , $ options );
313
-
314
309
$ operation = new CountDocuments ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
315
310
316
- return $ operation ->execute ($ server );
311
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
317
312
}
318
313
319
314
/**
@@ -367,13 +362,11 @@ public function createIndex($key, array $options = [])
367
362
*/
368
363
public function createIndexes (array $ indexes , array $ options = [])
369
364
{
370
- $ server = select_server ($ this ->manager , $ options );
371
-
372
365
$ options = $ this ->inheritWriteOptions ($ options );
373
366
374
367
$ operation = new CreateIndexes ($ this ->databaseName , $ this ->collectionName , $ indexes , $ options );
375
368
376
- return $ operation ->execute ($ server );
369
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
377
370
}
378
371
379
372
/**
@@ -393,9 +386,8 @@ public function deleteMany($filter, array $options = [])
393
386
$ options = $ this ->inheritWriteOptions ($ options );
394
387
395
388
$ operation = new DeleteMany ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
396
- $ server = select_server ($ this ->manager , $ options );
397
389
398
- return $ operation ->execute ($ server );
390
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
399
391
}
400
392
401
393
/**
@@ -415,9 +407,8 @@ public function deleteOne($filter, array $options = [])
415
407
$ options = $ this ->inheritWriteOptions ($ options );
416
408
417
409
$ operation = new DeleteOne ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
418
- $ server = select_server ($ this ->manager , $ options );
419
410
420
- return $ operation ->execute ($ server );
411
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
421
412
}
422
413
423
414
/**
@@ -439,11 +430,9 @@ public function distinct(string $fieldName, $filter = [], array $options = [])
439
430
$ this ->inheritTypeMap ($ options ),
440
431
);
441
432
442
- $ server = select_server ($ this ->manager , $ options );
443
-
444
433
$ operation = new Distinct ($ this ->databaseName , $ this ->collectionName , $ fieldName , $ filter , $ options );
445
434
446
- return $ operation ->execute ($ server );
435
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
447
436
}
448
437
449
438
/**
@@ -495,15 +484,13 @@ public function dropIndex($indexName, array $options = [])
495
484
throw new InvalidArgumentException ('dropIndexes() must be used to drop multiple indexes ' );
496
485
}
497
486
498
- $ server = select_server ($ this ->manager , $ options );
499
-
500
487
$ options = $ this ->inheritWriteOptions (
501
488
$ this ->inheritTypeMap ($ options ),
502
489
);
503
490
504
491
$ operation = new DropIndexes ($ this ->databaseName , $ this ->collectionName , $ indexName , $ options );
505
492
506
- return $ operation ->execute ($ server );
493
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
507
494
}
508
495
509
496
/**
@@ -518,15 +505,13 @@ public function dropIndex($indexName, array $options = [])
518
505
*/
519
506
public function dropIndexes (array $ options = [])
520
507
{
521
- $ server = select_server ($ this ->manager , $ options );
522
-
523
508
$ options = $ this ->inheritWriteOptions (
524
509
$ this ->inheritTypeMap ($ options ),
525
510
);
526
511
527
512
$ operation = new DropIndexes ($ this ->databaseName , $ this ->collectionName , '* ' , $ options );
528
513
529
- return $ operation ->execute ($ server );
514
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
530
515
}
531
516
532
517
/**
@@ -544,11 +529,9 @@ public function estimatedDocumentCount(array $options = [])
544
529
{
545
530
$ options = $ this ->inheritReadOptions ($ options );
546
531
547
- $ server = select_server ($ this ->manager , $ options );
548
-
549
532
$ operation = new EstimatedDocumentCount ($ this ->databaseName , $ this ->collectionName , $ options );
550
533
551
- return $ operation ->execute ($ server );
534
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
552
535
}
553
536
554
537
/**
@@ -571,11 +554,9 @@ public function explain(Explainable $explainable, array $options = [])
571
554
572
555
$ options = $ this ->inheritTypeMap ($ options );
573
556
574
- $ server = select_server ($ this ->manager , $ options );
575
-
576
557
$ operation = new Explain ($ this ->databaseName , $ explainable , $ options );
577
558
578
- return $ operation ->execute ($ server );
559
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
579
560
}
580
561
581
562
/**
@@ -596,11 +577,9 @@ public function find($filter = [], array $options = [])
596
577
$ this ->inheritCodecOrTypeMap ($ options ),
597
578
);
598
579
599
- $ server = select_server ($ this ->manager , $ options );
600
-
601
580
$ operation = new Find ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
602
581
603
- return $ operation ->execute ($ server );
582
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
604
583
}
605
584
606
585
/**
@@ -621,11 +600,9 @@ public function findOne($filter = [], array $options = [])
621
600
$ this ->inheritCodecOrTypeMap ($ options ),
622
601
);
623
602
624
- $ server = select_server ($ this ->manager , $ options );
625
-
626
603
$ operation = new FindOne ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
627
604
628
- return $ operation ->execute ($ server );
605
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
629
606
}
630
607
631
608
/**
@@ -645,15 +622,13 @@ public function findOne($filter = [], array $options = [])
645
622
*/
646
623
public function findOneAndDelete ($ filter , array $ options = [])
647
624
{
648
- $ server = select_server ($ this ->manager , $ options );
649
-
650
625
$ options = $ this ->inheritWriteOptions (
651
626
$ this ->inheritCodecOrTypeMap ($ options ),
652
627
);
653
628
654
629
$ operation = new FindOneAndDelete ($ this ->databaseName , $ this ->collectionName , $ filter , $ options );
655
630
656
- return $ operation ->execute ($ server );
631
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
657
632
}
658
633
659
634
/**
@@ -678,15 +653,13 @@ public function findOneAndDelete($filter, array $options = [])
678
653
*/
679
654
public function findOneAndReplace ($ filter , $ replacement , array $ options = [])
680
655
{
681
- $ server = select_server ($ this ->manager , $ options );
682
-
683
656
$ options = $ this ->inheritWriteOptions (
684
657
$ this ->inheritCodecOrTypeMap ($ options ),
685
658
);
686
659
687
660
$ operation = new FindOneAndReplace ($ this ->databaseName , $ this ->collectionName , $ filter , $ replacement , $ options );
688
661
689
- return $ operation ->execute ($ server );
662
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
690
663
}
691
664
692
665
/**
@@ -711,15 +684,13 @@ public function findOneAndReplace($filter, $replacement, array $options = [])
711
684
*/
712
685
public function findOneAndUpdate ($ filter , $ update , array $ options = [])
713
686
{
714
- $ server = select_server ($ this ->manager , $ options );
715
-
716
687
$ options = $ this ->inheritWriteOptions (
717
688
$ this ->inheritCodecOrTypeMap ($ options ),
718
689
);
719
690
720
691
$ operation = new FindOneAndUpdate ($ this ->databaseName , $ this ->collectionName , $ filter , $ update , $ options );
721
692
722
- return $ operation ->execute ($ server );
693
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
723
694
}
724
695
725
696
/**
@@ -823,9 +794,8 @@ public function insertMany(array $documents, array $options = [])
823
794
);
824
795
825
796
$ operation = new InsertMany ($ this ->databaseName , $ this ->collectionName , $ documents , $ options );
826
- $ server = select_server ($ this ->manager , $ options );
827
797
828
- return $ operation ->execute ($ server );
798
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
829
799
}
830
800
831
801
/**
@@ -846,9 +816,8 @@ public function insertOne($document, array $options = [])
846
816
);
847
817
848
818
$ operation = new InsertOne ($ this ->databaseName , $ this ->collectionName , $ document , $ options );
849
- $ server = select_server ($ this ->manager , $ options );
850
819
851
- return $ operation ->execute ($ server );
820
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
852
821
}
853
822
854
823
/**
@@ -862,9 +831,8 @@ public function insertOne($document, array $options = [])
862
831
public function listIndexes (array $ options = [])
863
832
{
864
833
$ operation = new ListIndexes ($ this ->databaseName , $ this ->collectionName , $ options );
865
- $ server = select_server ($ this ->manager , $ options );
866
834
867
- return $ operation ->execute ($ server );
835
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
868
836
}
869
837
870
838
/**
@@ -895,8 +863,6 @@ public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce,
895
863
$ options ['readPreference ' ] = new ReadPreference (ReadPreference::PRIMARY );
896
864
}
897
865
898
- $ server = select_server ($ this ->manager , $ options );
899
-
900
866
/* A "majority" read concern is not compatible with inline output, so
901
867
* avoid providing the Collection's read concern if it would conflict.
902
868
*
@@ -912,7 +878,7 @@ public function mapReduce(JavascriptInterface $map, JavascriptInterface $reduce,
912
878
913
879
$ operation = new MapReduce ($ this ->databaseName , $ this ->collectionName , $ map , $ reduce , $ out , $ options );
914
880
915
- return $ operation ->execute ($ server );
881
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
916
882
}
917
883
918
884
/**
@@ -933,15 +899,13 @@ public function rename(string $toCollectionName, ?string $toDatabaseName = null,
933
899
$ toDatabaseName = $ this ->databaseName ;
934
900
}
935
901
936
- $ server = select_server ($ this ->manager , $ options );
937
-
938
902
$ options = $ this ->inheritWriteOptions (
939
903
$ this ->inheritTypeMap ($ options ),
940
904
);
941
905
942
906
$ operation = new RenameCollection ($ this ->databaseName , $ this ->collectionName , $ toDatabaseName , $ toCollectionName , $ options );
943
907
944
- return $ operation ->execute ($ server );
908
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
945
909
}
946
910
947
911
/**
@@ -964,9 +928,8 @@ public function replaceOne($filter, $replacement, array $options = [])
964
928
);
965
929
966
930
$ operation = new ReplaceOne ($ this ->databaseName , $ this ->collectionName , $ filter , $ replacement , $ options );
967
- $ server = select_server ($ this ->manager , $ options );
968
931
969
- return $ operation ->execute ($ server );
932
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
970
933
}
971
934
972
935
/**
@@ -987,9 +950,8 @@ public function updateMany($filter, $update, array $options = [])
987
950
$ options = $ this ->inheritWriteOptions ($ options );
988
951
989
952
$ operation = new UpdateMany ($ this ->databaseName , $ this ->collectionName , $ filter , $ update , $ options );
990
- $ server = select_server ($ this ->manager , $ options );
991
953
992
- return $ operation ->execute ($ server );
954
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
993
955
}
994
956
995
957
/**
@@ -1010,9 +972,8 @@ public function updateOne($filter, $update, array $options = [])
1010
972
$ options = $ this ->inheritWriteOptions ($ options );
1011
973
1012
974
$ operation = new UpdateOne ($ this ->databaseName , $ this ->collectionName , $ filter , $ update , $ options );
1013
- $ server = select_server ($ this ->manager , $ options );
1014
975
1015
- return $ operation ->execute ($ server );
976
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
1016
977
}
1017
978
1018
979
/**
@@ -1030,11 +991,9 @@ public function watch(array $pipeline = [], array $options = [])
1030
991
$ this ->inheritCodecOrTypeMap ($ options ),
1031
992
);
1032
993
1033
- $ server = select_server ($ this ->manager , $ options );
1034
-
1035
994
$ operation = new Watch ($ this ->manager , $ this ->databaseName , $ this ->collectionName , $ pipeline , $ options );
1036
995
1037
- return $ operation ->execute ($ server );
996
+ return $ operation ->execute (select_server ( $ this -> manager , $ options ) );
1038
997
}
1039
998
1040
999
/**
0 commit comments