From f7c02d9308039aed8c540c31dc9e68fd4bbc0ae3 Mon Sep 17 00:00:00 2001 From: Prateek Banga Date: Mon, 24 Jul 2023 23:41:49 +0530 Subject: [PATCH] removes extra db call and uses document find method --- app/controllers/api/databases.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 4f2f42c849..c815954747 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2535,13 +2535,12 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/indexes/:key') throw new Exception(Exception::COLLECTION_NOT_FOUND); } - $index = $dbForProject->find('indexes', [Query::equal('$id', [$database->getInternalId() . '_' . $collection->getInternalId() . '_' . $key]), Query::limit(1)]); - + $index = $collection->find('key', $key, 'indexes'); if (empty($index)) { throw new Exception(Exception::INDEX_NOT_FOUND); } - $response->dynamic($index[0], Response::MODEL_INDEX); + $response->dynamic($index, Response::MODEL_INDEX); });