@@ -3456,7 +3456,7 @@ public function createDocument(string $collection, Document $document): Document
34563456 * @param array<Document> $documents
34573457 * @param callable|null $onNext
34583458 * @param int $batchSize
3459- * @return void
3459+ * @return int
34603460 * @throws AuthorizationException
34613461 * @throws StructureException
34623462 * @throws \Throwable
@@ -3473,7 +3473,7 @@ public function createDocuments(
34733473 }
34743474
34753475 if (empty ($ documents )) {
3476- return ;
3476+ return 0 ;
34773477 }
34783478
34793479 $ batchSize = \min (Database::INSERT_BATCH_SIZE , \max (1 , $ batchSize ));
@@ -3525,7 +3525,7 @@ public function createDocuments(
35253525 }
35263526
35273527 foreach (\array_chunk ($ documents , $ batchSize ) as $ chunk ) {
3528- $ batch = $ this ->withTransaction (function () use ($ collection , $ chunk, $ onNext , & $ modified ) {
3528+ $ batch = $ this ->withTransaction (function () use ($ collection , $ chunk ) {
35293529 return $ this ->adapter ->createDocuments ($ collection ->getId (), $ chunk );
35303530 });
35313531
@@ -4079,7 +4079,7 @@ public function updateDocument(string $collection, string $id, Document $documen
40794079 * @param array<Query> $queries
40804080 * @param callable|null $onNext
40814081 * @param int $batchSize
4082- * @return void
4082+ * @return int
40834083 * @throws AuthorizationException
40844084 * @throws ConflictException
40854085 * @throws DuplicateException
@@ -4095,9 +4095,9 @@ public function updateDocuments(
40954095 array $ queries = [],
40964096 ?callable $ onNext = null ,
40974097 int $ batchSize = self ::INSERT_BATCH_SIZE
4098- ): void {
4098+ ): int {
40994099 if ($ updates ->isEmpty ()) {
4100- return ;
4100+ return 0 ;
41014101 }
41024102
41034103 $ batchSize = \min (Database::INSERT_BATCH_SIZE , \max (1 , $ batchSize ));
@@ -4161,7 +4161,7 @@ public function updateDocuments(
41614161 }
41624162
41634163 $ originalLimit = $ limit ;
4164- $ lastDocument = $ cursor ;
4164+ $ last = $ cursor ;
41654165 $ modified = 0 ;
41664166
41674167 // Resolve and update relationships
@@ -4176,8 +4176,8 @@ public function updateDocuments(
41764176 Query::limit ($ batchSize )
41774177 ];
41784178
4179- if (!empty ($ lastDocument )) {
4180- $ new [] = Query::cursorAfter ($ lastDocument );
4179+ if (!empty ($ last )) {
4180+ $ new [] = Query::cursorAfter ($ last );
41814181 }
41824182
41834183 $ affectedDocuments = $ this ->silent (fn () => $ this ->find (
@@ -4240,13 +4240,15 @@ public function updateDocuments(
42404240 break ;
42414241 }
42424242
4243- $ lastDocument = \end ($ affectedDocuments );
4243+ $ last = \end ($ affectedDocuments );
42444244 }
42454245
42464246 $ this ->trigger (self ::EVENT_DOCUMENTS_UPDATE , new Document ([
42474247 '$collection ' => $ collection ->getId (),
42484248 'modified ' => $ modified
42494249 ]));
4250+
4251+ return $ modified ;
42504252 }
42514253
42524254 /**
@@ -5454,7 +5456,7 @@ private function deleteCascade(Document $collection, Document $relatedCollection
54545456 * @param array<Query> $queries
54555457 * @param callable|null $onNext
54565458 * @param int $batchSize
5457- * @return void
5459+ * @return int
54585460 * @throws AuthorizationException
54595461 * @throws DatabaseException
54605462 * @throws RestrictedException
@@ -5465,7 +5467,7 @@ public function deleteDocuments(
54655467 array $ queries = [],
54665468 ?callable $ onNext = null ,
54675469 int $ batchSize = self ::DELETE_BATCH_SIZE
5468- ): void {
5470+ ): int {
54695471 if ($ this ->adapter ->getSharedTables () && empty ($ this ->adapter ->getTenant ())) {
54705472 throw new DatabaseException ('Missing tenant. Tenant must be set when table sharing is enabled. ' );
54715473 }
@@ -5510,7 +5512,7 @@ public function deleteDocuments(
55105512 }
55115513
55125514 $ originalLimit = $ limit ;
5513- $ lastDocument = $ cursor ;
5515+ $ last = $ cursor ;
55145516 $ modified = 0 ;
55155517
55165518 while (true ) {
@@ -5524,8 +5526,8 @@ public function deleteDocuments(
55245526 Query::limit ($ batchSize )
55255527 ];
55265528
5527- if (!empty ($ lastDocument )) {
5528- $ new [] = Query::cursorAfter ($ lastDocument );
5529+ if (!empty ($ last )) {
5530+ $ new [] = Query::cursorAfter ($ last );
55295531 }
55305532
55315533 /**
@@ -5599,13 +5601,15 @@ public function deleteDocuments(
55995601 break ;
56005602 }
56015603
5602- $ lastDocument = \end ($ affectedDocuments );
5604+ $ last = \end ($ affectedDocuments );
56035605 }
56045606
56055607 $ this ->trigger (self ::EVENT_DOCUMENTS_DELETE , new Document ([
56065608 '$collection ' => $ collection ->getId (),
56075609 'modified ' => $ modified
56085610 ]));
5611+
5612+ return $ modified ;
56095613 }
56105614
56115615 /**
0 commit comments