mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 08:58:35 +00:00
Merge pull request #9643 from appwrite/feat-bulk-callbacks
Update database
This commit is contained in:
commit
0b60898ad5
4 changed files with 20 additions and 27 deletions
|
|
@ -51,7 +51,7 @@
|
|||
"utopia-php/cache": "0.12.*",
|
||||
"utopia-php/cli": "0.15.*",
|
||||
"utopia-php/config": "0.2.*",
|
||||
"utopia-php/database": "0.64.*",
|
||||
"utopia-php/database": "0.65.*",
|
||||
"utopia-php/domains": "0.5.*",
|
||||
"utopia-php/dsn": "0.2.1",
|
||||
"utopia-php/framework": "0.33.*",
|
||||
|
|
|
|||
14
composer.lock
generated
14
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "6a54c8bc4f9f14cd3883f55880864630",
|
||||
"content-hash": "51ff891ef6cee8a3f8c4e5187b7fd479",
|
||||
"packages": [
|
||||
{
|
||||
"name": "adhocore/jwt",
|
||||
|
|
@ -3497,16 +3497,16 @@
|
|||
},
|
||||
{
|
||||
"name": "utopia-php/database",
|
||||
"version": "0.64.2",
|
||||
"version": "0.65.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/utopia-php/database.git",
|
||||
"reference": "dc9c4a68c93e8bea2dfaa76d1ba308be539998bd"
|
||||
"reference": "e589efdc5da1216523a758e8af358866d4fb563f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/dc9c4a68c93e8bea2dfaa76d1ba308be539998bd",
|
||||
"reference": "dc9c4a68c93e8bea2dfaa76d1ba308be539998bd",
|
||||
"url": "https://api.github.com/repos/utopia-php/database/zipball/e589efdc5da1216523a758e8af358866d4fb563f",
|
||||
"reference": "e589efdc5da1216523a758e8af358866d4fb563f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
|
@ -3547,9 +3547,9 @@
|
|||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/utopia-php/database/issues",
|
||||
"source": "https://github.com/utopia-php/database/tree/0.64.2"
|
||||
"source": "https://github.com/utopia-php/database/tree/0.65.0"
|
||||
},
|
||||
"time": "2025-04-09T07:53:05+00:00"
|
||||
"time": "2025-04-14T07:39:01+00:00"
|
||||
},
|
||||
{
|
||||
"name": "utopia-php/domains",
|
||||
|
|
|
|||
|
|
@ -563,22 +563,19 @@ class Databases extends Action
|
|||
$start = \microtime(true);
|
||||
|
||||
try {
|
||||
$documents = $database->deleteDocuments($collectionId, $queries);
|
||||
$count = $database->deleteDocuments(
|
||||
$collectionId,
|
||||
$queries,
|
||||
Database::DELETE_BATCH_SIZE,
|
||||
$callback
|
||||
);
|
||||
} catch (\Throwable $th) {
|
||||
$tenant = $database->getSharedTables() ? 'Tenant:'.$database->getTenant() : '';
|
||||
Console::error("Failed to delete documents for collection:{$database->getNamespace()}_{$collectionId} {$tenant} :{$th->getMessage()}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (\is_callable($callback)) {
|
||||
foreach ($documents as $document) {
|
||||
$callback($document);
|
||||
}
|
||||
}
|
||||
|
||||
$end = \microtime(true);
|
||||
$count = \count($documents);
|
||||
|
||||
Console::info("Deleted {$count} documents by group in " . ($end - $start) . " seconds");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1050,24 +1050,20 @@ class Deletes extends Action
|
|||
/**
|
||||
* deleteDocuments uses a cursor, we need to add a unique order by field or use default
|
||||
*/
|
||||
|
||||
try {
|
||||
$documents = $database->deleteDocuments($collection, $queries);
|
||||
$count = $database->deleteDocuments(
|
||||
$collection,
|
||||
$queries,
|
||||
Database::DELETE_BATCH_SIZE,
|
||||
$callback
|
||||
);
|
||||
} catch (Throwable $th) {
|
||||
$tenant = $database->getSharedTables() ? 'Tenant:'.$database->getTenant() : '';
|
||||
Console::error("Failed to delete documents for collection:{$database->getNamespace()}_{$collection} {$tenant} :{$th->getMessage()}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (\is_callable($callback)) {
|
||||
foreach ($documents as $document) {
|
||||
$callback($document);
|
||||
}
|
||||
}
|
||||
|
||||
$end = \microtime(true);
|
||||
$count = \count($documents);
|
||||
|
||||
Console::info("Deleted {$count} documents by group in " . ($end - $start) . " seconds");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue