Databases API fixes
This commit is contained in:
parent
58ffde5326
commit
bc098d73fa
|
@ -1713,15 +1713,14 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/indexes/:key')
|
||||||
$indexes = $collection->getAttribute('indexes');
|
$indexes = $collection->getAttribute('indexes');
|
||||||
|
|
||||||
// Search for index
|
// Search for index
|
||||||
$indexIndex = array_search($key, array_column($indexes, 'key'));
|
$indexIndex = array_search($key, array_map(fn($idx) => $idx['key'], $indexes));
|
||||||
|
|
||||||
if ($indexIndex === false) {
|
if ($indexIndex === false) {
|
||||||
throw new Exception('Index not found', 404, Exception::INDEX_NOT_FOUND);
|
throw new Exception('Index not found', 404, Exception::INDEX_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
$index = new Document([\array_merge($indexes[$indexIndex], [
|
$index = $indexes[$indexIndex];
|
||||||
'collectionId' => $database->getInternalId() . '_' . $collectionId,
|
$index->setAttribute('collectionId', $database->getInternalId() . '_' . $collectionId);
|
||||||
])]);
|
|
||||||
|
|
||||||
$usage
|
$usage
|
||||||
->setParam('databaseId', $databaseId)
|
->setParam('databaseId', $databaseId)
|
||||||
|
@ -2562,6 +2561,7 @@ App::get('/v1/databases/usage')
|
||||||
});
|
});
|
||||||
|
|
||||||
App::get('/v1/databases/:databaseId/usage')
|
App::get('/v1/databases/:databaseId/usage')
|
||||||
|
->alias('/v1/database/usage', ['databaseId' => 'default'])
|
||||||
->desc('Get usage stats for the database')
|
->desc('Get usage stats for the database')
|
||||||
->groups(['api', 'database'])
|
->groups(['api', 'database'])
|
||||||
->label('scope', 'collections.read')
|
->label('scope', 'collections.read')
|
||||||
|
@ -2669,7 +2669,7 @@ App::get('/v1/databases/:databaseId/usage')
|
||||||
});
|
});
|
||||||
|
|
||||||
App::get('/v1/databases/:databaseId/collections/:collectionId/usage')
|
App::get('/v1/databases/:databaseId/collections/:collectionId/usage')
|
||||||
->alias('/v1/database/collections/:collectionId/documents', ['databaseId' => 'default'])
|
->alias('/v1/database/collections/:collectionId/usage', ['databaseId' => 'default'])
|
||||||
->desc('Get usage stats for a collection')
|
->desc('Get usage stats for a collection')
|
||||||
->groups(['api', 'database'])
|
->groups(['api', 'database'])
|
||||||
->label('scope', 'collections.read')
|
->label('scope', 'collections.read')
|
||||||
|
|
Loading…
Reference in a new issue