diff --git a/app/controllers/api/database.php b/app/controllers/api/database.php index 3cb5c6c470..cb3a016ce8 100644 --- a/app/controllers/api/database.php +++ b/app/controllers/api/database.php @@ -7,9 +7,6 @@ use Utopia\Validator\WhiteList; use Utopia\Validator\Text; use Utopia\Validator\ArrayList; use Utopia\Validator\JSON; -// use Utopia\Locale\Locale; -// use Utopia\Audit\Audit; -// use Utopia\Audit\Adapters\MySQL as AuditAdapter; use Appwrite\Database\Database; use Appwrite\Database\Document; use Appwrite\Database\Validator\UID; @@ -403,24 +400,24 @@ App::get('/v1/database/collections/:collectionId/documents') ]), ]); - if (App::isDevelopment()) { - $collection - ->setAttribute('debug', $projectDB->getDebug()) - ->setAttribute('limit', $limit) - ->setAttribute('offset', $offset) - ->setAttribute('orderField', $orderField) - ->setAttribute('orderType', $orderType) - ->setAttribute('orderCast', $orderCast) - ->setAttribute('filters', $filters) - ; - } + // if (App::isDevelopment()) { + // $collection + // ->setAttribute('debug', $projectDB->getDebug()) + // ->setAttribute('limit', $limit) + // ->setAttribute('offset', $offset) + // ->setAttribute('orderField', $orderField) + // ->setAttribute('orderType', $orderType) + // ->setAttribute('orderCast', $orderCast) + // ->setAttribute('filters', $filters) + // ; + // } $collection ->setAttribute('sum', $projectDB->getSum()) ->setAttribute('documents', $list) ; - $response->json($collection->getArrayCopy(/*['$id', '$collection', 'name', 'documents']*/[], ['rules'])); + $response->dynamic($collection, Response::MODEL_DOCUMENT_LIST); }, ['response', 'projectDB']); App::get('/v1/database/collections/:collectionId/documents/:documentId') diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 91f7976b25..d40a58471d 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -50,6 +50,7 @@ class Response extends SwooleResponse const MODEL_COLLECTION = 'collection'; const MODEL_COLLECTION_LIST = 'collectionList'; const MODEL_RULE = 'rule'; + const MODEL_DOCUMENT_LIST = 'documentList'; // Users const MODEL_USER = 'user'; @@ -120,6 +121,7 @@ class Response extends SwooleResponse ->setModel(new ErrorDev()) // Lists ->setModel(new BaseList('Collections List', self::MODEL_COLLECTION_LIST, 'collections', self::MODEL_COLLECTION)) + ->setModel(new BaseList('Documents List', self::MODEL_DOCUMENT_LIST, 'documents', self::MODEL_ANY)) ->setModel(new BaseList('Users List', self::MODEL_USER_LIST, 'users', self::MODEL_USER)) ->setModel(new BaseList('Sessions List', self::MODEL_SESSION_LIST, 'sessions', self::MODEL_SESSION)) ->setModel(new BaseList('Logs List', self::MODEL_LOG_LIST, 'logs', self::MODEL_LOG, false))