@@ -340,6 +340,7 @@ public function createCollection(string $name, array $attributes = [], array $in
340340 // Returns an array/object with the result document
341341 try {
342342 $ this ->getClient ()->createCollection ($ id );
343+
343344 } catch (MongoException $ e ) {
344345 throw new Duplicate ($ e ->getMessage (), $ e ->getCode (), $ e );
345346 }
@@ -534,6 +535,7 @@ public function createAttributes(string $collection, array $attributes): bool
534535 public function deleteAttribute (string $ collection , string $ id ): bool
535536 {
536537 $ collection = $ this ->getNamespace () . '_ ' . $ this ->filter ($ collection );
538+
537539 $ this ->getClient ()->update (
538540 $ collection ,
539541 [],
@@ -734,6 +736,7 @@ public function createIndex(string $collection, string $id, string $type, array
734736 $ id = $ this ->filter ($ id );
735737
736738 $ indexes = [];
739+ $ options = [];
737740
738741 // pass in custom index name
739742 $ indexes ['name ' ] = $ id ;
@@ -774,7 +777,7 @@ public function createIndex(string $collection, string $id, string $type, array
774777 ];
775778 }
776779
777- return $ this ->client ->createIndexes ($ name , [$ indexes ]);
780+ return $ this ->client ->createIndexes ($ name , [$ indexes ], $ options );
778781 }
779782
780783 /**
@@ -865,7 +868,7 @@ public function getDocument(string $collection, string $id, array $queries = [],
865868 }
866869
867870 $ result = $ this ->client ->find ($ name , $ filters , $ options )->cursor ->firstBatch ;
868-
871+
869872 if (empty ($ result )) {
870873 return new Document ([]);
871874 }
@@ -927,7 +930,6 @@ public function createDocuments(string $collection, array $documents): array
927930 {
928931 $ name = $ this ->getNamespace () . '_ ' . $ this ->filter ($ collection );
929932
930- // Initialize transaction context before validation to ensure transaction is active
931933 $ options = $ this ->addTransactionContext ([]);
932934
933935 $ records = [];
@@ -1081,7 +1083,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
10811083 if (empty ($ changes )) {
10821084 return $ changes ;
10831085 }
1084-
1086+
10851087 try {
10861088 $ name = $ this ->getNamespace () . '_ ' . $ this ->filter ($ collection );
10871089 $ attribute = $ this ->filter ($ attribute );
@@ -1098,7 +1100,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
10981100 $ attributes ['_createdAt ' ] = $ document ->getCreatedAt ();
10991101 $ attributes ['_updatedAt ' ] = $ document ->getUpdatedAt ();
11001102 $ attributes ['_permissions ' ] = $ document ->getPermissions ();
1101-
1103+
11021104 if (!empty ($ document ->getSequence ())) {
11031105 $ attributes ['_id ' ] = new ObjectId ($ document ->getSequence ());
11041106 } else {
@@ -1113,7 +1115,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
11131115 $ record = $ this ->replaceChars ('$ ' , '_ ' , $ attributes );
11141116 $ record = $ this ->timeToMongo ($ record );
11151117 $ record = $ this ->removeNullKeys ($ record );
1116-
1118+
11171119
11181120 // Build filter for upsert
11191121 $ filter = ['_uid ' => $ document ->getId ()];
@@ -1149,7 +1151,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
11491151 // Get sequences for documents that were created
11501152 if (!empty ($ documentIds )) {
11511153 $ sequences = $ this ->getSequences ($ collection , $ documentIds , $ documentTenants );
1152-
1154+
11531155 foreach ($ changes as $ change ) {
11541156 if (isset ($ sequences [$ change ->getNew ()->getId ()])) {
11551157 $ change ->getNew ()->setAttribute ('$sequence ' , $ sequences [$ change ->getNew ()->getId ()]);
@@ -1160,7 +1162,7 @@ public function createOrUpdateDocuments(string $collection, string $attribute, a
11601162 } catch (MongoException $ e ) {
11611163 throw $ this ->processException ($ e );
11621164 }
1163-
1165+
11641166 return \array_map (fn ($ change ) => $ change ->getNew (), $ changes );
11651167 }
11661168
@@ -1189,7 +1191,7 @@ protected function getSequences(string $collection, array $documentIds, array $d
11891191
11901192 try {
11911193 $ results = $ this ->client ->find ($ name , $ filters , ['projection ' => ['_uid ' => 1 , '_id ' => 1 ]]);
1192-
1194+
11931195 foreach ($ results ->cursor ->firstBatch as $ result ) {
11941196 $ sequences [$ result ->_uid ] = (string )$ result ->_id ;
11951197 }
0 commit comments