1
0
Fork 0
mirror of synced 2024-06-02 19:04:49 +12:00

Prefer single query to internal DB

This commit is contained in:
kodumbeats 2021-08-27 20:32:44 -04:00
parent c3534b4383
commit 559fe95b7c

View file

@ -802,9 +802,7 @@ App::get('/v1/database/collections/:collectionId/attributes')
throw new Exception('Collection not found', 404);
}
$attributes = $dbForInternal->find('attributes', [
new Query('collectionId', Query::TYPE_EQUAL, [$collection->getId()])
], 100);
$attributes = $collection->getAttribute('attributes');
$response->dynamic(new Document([
'sum' => \count($attributes),
@ -837,9 +835,9 @@ App::get('/v1/database/collections/:collectionId/attributes/:attributeId')
throw new Exception('Collection not found', 404);
}
$attribute = $dbForInternal->getDocument('attributes', $attributeId);
$attribute = $collection->find('$id', $attributeId, 'attributes');
if ($attribute === false) {
if (!$attribute) {
throw new Exception('Attribute not found', 404);
}