diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 414bec3c4a..8df90b8fcf 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -1752,15 +1752,14 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/indexes/:key') $indexes = $collection->getAttribute('indexes'); // 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) { throw new Exception(Exception::INDEX_NOT_FOUND); } - $index = new Document([\array_merge($indexes[$indexIndex], [ - 'collectionId' => $database->getInternalId() . '_' . $collectionId, - ])]); + $index = $indexes[$indexIndex]; + $index->setAttribute('collectionId', $database->getInternalId() . '_' . $collectionId); $response->dynamic($index, Response::MODEL_INDEX); });