database crud usage addition

This commit is contained in:
shimon
2024-12-29 17:57:29 +02:00
parent 025c9aeeb2
commit 8e17fc69b3
+4 -2
View File
@@ -2898,8 +2898,10 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
throw new Exception(Exception::DATABASE_NOT_FOUND);
}
$collection = Authorization::skip(fn () => $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionId));
$queueForUsage->addMetric(METRIC_DATABASE_API_READ, 1);
$collection = Authorization::skip(function () use ($queueForUsage, $dbForProject, $database, $collectionId){
$queueForUsage->addMetric(METRIC_DATABASE_API_READ, 1);
return $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionId);
});
if ($collection->isEmpty() || (!$collection->getAttribute('enabled', false) && !$isAPIKey && !$isPrivilegedUser)) {
throw new Exception(Exception::COLLECTION_NOT_FOUND);