diff --git a/app/config/collections.php b/app/config/collections.php index 5b6e697f13..6f55516305 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -748,6 +748,13 @@ $collections = [ 'lengths' => [128], 'orders' => [Database::ORDER_ASC], ], + [ + '$id' => ID::custom('_key_team'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['teamId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], ], ], diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Projects.php b/src/Appwrite/Utopia/Database/Validator/Queries/Projects.php index cf2bea911a..7fff26db7f 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Projects.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Projects.php @@ -7,7 +7,8 @@ use Appwrite\Utopia\Database\Validator\Queries\Base; class Projects extends Base { public const ALLOWED_ATTRIBUTES = [ - 'name' + 'name', + 'teamId' ]; /** diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 4c4d2e5213..592a09b4fc 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -167,6 +167,18 @@ class ProjectsConsoleClientTest extends Scope $this->assertArrayHasKey('webhooks', $response['body']); $this->assertArrayHasKey('keys', $response['body']); + $response = $this->client->call(Client::METHOD_GET, '/projects', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'queries' => [ 'equal("teamId", "' . $team['body']['$id'] . '")' ], + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']); + $this->assertCount(1, $response['body']['projects']); + $this->assertEquals($team['body']['$id'], $response['body']['projects'][0]['teamId']); + $response = $this->client->call(Client::METHOD_GET, '/projects', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'],