From 2e0b7fe471fe1c8021ca3e040907d56411df674c Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Fri, 18 Jun 2021 15:27:16 -0400 Subject: [PATCH] Support queries for listCollections --- app/controllers/api/database.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 9e528d1677..f006893183 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -76,16 +76,20 @@ App::get('/v1/database/collections') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_COLLECTION_LIST) + ->param('queries', [], new ArrayList(new Text(128)), 'Array of query strings.', true) ->param('limit', 25, new Range(0, 100), 'Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request.', true) ->param('offset', 0, new Range(0, 40000), 'Results offset. The default value is 0. Use this param to manage pagination.', true) ->inject('response') ->inject('dbForExternal') - ->action(function ($limit, $offset, $response, $dbForExternal) { + ->action(function ($queries, $limit, $offset, $response, $dbForExternal) { /** @var Appwrite\Utopia\Response $response */ /** @var Utopia\Database\Database $dbForExternal */ - $collections = $dbForExternal->listCollections($limit, $offset); - // TODO@kodumbeats allow for filtering collections + $queries = \array_map(function ($query) { + return Query::parse($query); + }, $queries); + + $collections = $dbForExternal->find(Database::COLLECTIONS, $queries, $limit, $offset); $response->dynamic2(new Document([ 'collections' => $collections,