Skip to content

Commit 05c0ce2

Browse files
committed
Use getDocument
1 parent 6d483e7 commit 05c0ce2

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

src/Database/Database.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5797,11 +5797,13 @@ public function deleteDocuments(
57975797
*/
57985798

57995799
$batch = $this->silent(fn () =>
5800-
$this->withCursor($last, fn () => $this->find(
5801-
$collection->getId(),
5802-
array_merge($new, $queries),
5803-
forPermission: Database::PERMISSION_DELETE
5804-
)));
5800+
5801+
$this->withCursor($last, fn () =>
5802+
$this->find(
5803+
$collection->getId(),
5804+
array_merge($new, $queries),
5805+
forPermission: Database::PERMISSION_DELETE
5806+
)));
58055807

58065808
if (empty($batch)) {
58075809
break;
@@ -5834,6 +5836,15 @@ public function deleteDocuments(
58345836
}
58355837
}
58365838

5839+
$last = $batch[array_key_last($batch)];
5840+
$cursor = $last->getId();
5841+
/**
5842+
* Independent Cursor data.
5843+
* todo: add specific selects... (order by , $id, $internalId))
5844+
* Do we need silent here?
5845+
*/
5846+
$last = $this->silent(fn () => $this->getDocument($collection->getId(), $cursor));
5847+
58375848
$this->withTransaction(function () use ($collection, $internalIds, $permissionIds) {
58385849
$this->adapter->deleteDocuments(
58395850
$collection->getId(),
@@ -5860,10 +5871,6 @@ public function deleteDocuments(
58605871
} elseif ($originalLimit && $modified >= $originalLimit) {
58615872
break;
58625873
}
5863-
5864-
$last = $batch[array_key_last($batch)];
5865-
5866-
$cursor = $last->getId();
58675874
}
58685875

58695876
$this->trigger(self::EVENT_DOCUMENTS_DELETE, new Document([

0 commit comments

Comments
 (0)