Merge branch 'response-filters-for-databases' into events-compatibility

This commit is contained in:
Darshan 2025-05-06 12:17:02 +05:30
commit a0ffcd54dc
28 changed files with 351 additions and 367 deletions

View file

@ -353,7 +353,7 @@ App::get('/v1/project/usage')
'executionsTotal' => $total[METRIC_EXECUTIONS],
'executionsMbSecondsTotal' => $total[METRIC_EXECUTIONS_MB_SECONDS],
'buildsMbSecondsTotal' => $total[METRIC_BUILDS_MB_SECONDS],
'documentsTotal' => $total[METRIC_DOCUMENTS],
'rowsTotal' => $total[METRIC_DOCUMENTS],
'databasesTotal' => $total[METRIC_DATABASES],
'databasesStorageTotal' => $total[METRIC_DATABASES_STORAGE],
'usersTotal' => $total[METRIC_USERS],

View file

@ -18,7 +18,6 @@ use Appwrite\SDK\Response as SDKResponse;
use Appwrite\Transformation\Adapter\Preview;
use Appwrite\Transformation\Transformation;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Request\Filters\DatabaseAliases;
use Appwrite\Utopia\Request\Filters\V16 as RequestV16;
use Appwrite\Utopia\Request\Filters\V17 as RequestV17;
use Appwrite\Utopia\Request\Filters\V18 as RequestV18;
@ -835,9 +834,6 @@ App::init()
}
}
// process on all databases endpoints!
$request->addFilter(new DatabaseAliases());
$domain = $request->getHostname();
$domains = Config::getParam('domains', []);
if (!array_key_exists($domain, $domains)) {

View file

@ -721,8 +721,8 @@ App::setResource('schema', function ($utopia, $dbForProject) {
// Order must be the same as the route params
return [
'databaseId' => $databaseId,
'documentId' => $id,
'collectionId' => $collectionId,
'rowId' => $id,
'tableId' => $collectionId,
'data' => $args,
'permissions' => $permissions,
];
@ -737,8 +737,8 @@ App::setResource('schema', function ($utopia, $dbForProject) {
// Order must be the same as the route params
return [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'documentId' => $documentId,
'tableId' => $collectionId,
'rowId' => $documentId,
'data' => $args,
'permissions' => $permissions,
];

View file

@ -418,8 +418,8 @@ class Mapper
// TODO: Find a better way to do this
switch ($name) {
case 'Attributes':
return static::getAttributeImplementation($object);
case 'Columns':
return static::getColumnImplementation($object);
case 'HashOptions':
return static::getHashOptionsImplementation($object);
}
@ -427,29 +427,29 @@ class Mapper
throw new Exception('Unknown union type: ' . $name);
}
private static function getAttributeImplementation(array $object): Type
private static function getColumnImplementation(array $object): Type
{
switch ($object['type']) {
case 'string':
return match ($object['format'] ?? '') {
'email' => static::model('AttributeEmail'),
'url' => static::model('AttributeUrl'),
'ip' => static::model('AttributeIp'),
default => static::model('AttributeString'),
'email' => static::model('ColumnEmail'),
'url' => static::model('ColumnUrl'),
'ip' => static::model('ColumnIp'),
default => static::model('ColumnString'),
};
case 'integer':
return static::model('AttributeInteger');
return static::model('ColumnInteger');
case 'double':
return static::model('AttributeFloat');
return static::model('ColumnFloat');
case 'boolean':
return static::model('AttributeBoolean');
return static::model('ColumnBoolean');
case 'datetime':
return static::model('AttributeDatetime');
return static::model('ColumnDatetime');
case 'relationship':
return static::model('AttributeRelationship');
return static::model('ColumnRelationship');
}
throw new Exception('Unknown attribute implementation');
throw new Exception('Unknown column implementation');
}
private static function getHashOptionsImplementation(array $object): Type

View file

@ -312,8 +312,8 @@ class Realtime extends Adapter
}
$channels[] = 'rows';
$channels[] = 'databases.' . $database->getId() . '.tables.' . $payload->getAttribute('$collectionId') . '.rows';
$channels[] = 'databases.' . $database->getId() . '.tables.' . $payload->getAttribute('$collectionId') . '.rows.' . $payload->getId();
$channels[] = 'databases.' . $database->getId() . '.tables.' . $payload->getAttribute('$tableId') . '.rows';
$channels[] = 'databases.' . $database->getId() . '.tables.' . $payload->getAttribute('$tableId') . '.rows.' . $payload->getId();
$roles = $table->getAttribute('documentSecurity', false)
? \array_merge($table->getRead(), $payload->getRead())

View file

@ -49,7 +49,7 @@ class XList extends Action
responses: [
new SDKResponse(
code: SwooleResponse::STATUS_CODE_OK,
model: UtopiaResponse::MODEL_TABLE,
model: UtopiaResponse::MODEL_TABLE_LIST,
)
],
contentType: ContentType::JSON

View file

@ -1,38 +0,0 @@
<?php
namespace Appwrite\Utopia\Request\Filters;
use Appwrite\Utopia\Request\Filter;
class DatabaseAliases extends Filter
{
// Map old params to new
private const PARAMS_MAP = [
'documentId' => 'rowId',
'attributes' => 'columns',
'collectionId' => 'tableId',
'attributeId' => 'columnId',
'relatedCollectionId' => 'relatedTableId'
];
public function parse(array $content, string $model): array
{
return $this->overrideDatabaseParams($content, $model);
}
protected function overrideDatabaseParams(array $content, string $model): array
{
if (!str_starts_with($model, 'databases.')) {
return $content;
}
$intersect = array_intersect_key(self::PARAMS_MAP, $content);
foreach ($intersect as $oldKey => $newKey) {
$content[$newKey] = $content[$oldKey];
unset($content[$oldKey]);
}
return $content;
}
}

View file

@ -6,20 +6,36 @@ use Appwrite\Utopia\Request\Filter;
class V19 extends Filter
{
// Map old params to new
private const PARAMS_MAP = [
'documentId' => 'rowId',
'attributes' => 'columns',
'collectionId' => 'tableId',
'attributeId' => 'columnId',
'$collectionId' => '$tableId',
'relatedCollection' => 'relatedTable',
'relatedCollectionId' => 'relatedTableId',
];
// Convert 1.6 params to 1.7
public function parse(array $content, string $model): array
{
return match ($model) {
'databases.createRelationshipColumn' => $this->convertV16RelationshipParams($content),
default => $content
};
$content = $this->overrideDatabaseParams($content, $model);
return $content;
}
protected function convertV16RelationshipParams(array $content): array
protected function overrideDatabaseParams(array $content, string $model): array
{
if (isset($content['relatedCollectionId'])) {
$content['relatedTableId'] = $content['relatedCollectionId'];
unset($content['relatedCollectionId']);
if (!str_starts_with($model, 'databases.')) {
return $content;
}
$intersect = array_intersect_key(self::PARAMS_MAP, $content);
foreach ($intersect as $oldKey => $newKey) {
$content[$newKey] = $content[$oldKey];
unset($content[$oldKey]);
}
return $content;

View file

@ -10,8 +10,10 @@ class V19 extends Filter
private const DATABASE_MAPPINGS = [
'table' => 'collection',
'tables' => 'collections',
'$tableId' => '$collectionId',
'tablesTotal' => 'collectionsTotal',
'relatedTable' => 'relatedCollection',
'relatedTableId' => 'relatedCollectionId',
'column' => 'attribute',
'columns' => 'attributes',

View file

@ -36,7 +36,7 @@ class Row extends Any
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('$collectionId', [
->addRule('$tableId', [
'type' => self::TYPE_STRING,
'description' => 'Table ID.',
'default' => '',
@ -75,6 +75,13 @@ class Row extends Any
$document->removeAttribute('$collection');
$document->removeAttribute('$tenant');
$collectionId = $document->getAttribute('$collectionId', '');
if (!empty($collectionId)) {
$document
->removeAttribute('$collectionId')
->setAttribute('$tableId', $collectionId);
}
foreach ($document->getAttributes() as $column) {
if (\is_array($column)) {
foreach ($column as $subAttribute) {

View file

@ -16,9 +16,9 @@ class UsageProject extends Model
'default' => 0,
'example' => 0,
])
->addRule('documentsTotal', [
->addRule('rowsTotal', [
'type' => self::TYPE_INTEGER,
'description' => 'Total aggregated number of documents.',
'description' => 'Total aggregated number of rows.',
'default' => 0,
'example' => 0,
])

View file

@ -30,7 +30,7 @@ class AbuseTest extends Scope
{
$data = $this->createCollection();
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$max = 120;
for ($i = 0; $i <= $max + 1; $i++) {
@ -38,7 +38,7 @@ class AbuseTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'The Hulk ' . $i,
],
@ -56,7 +56,7 @@ class AbuseTest extends Scope
{
$data = $this->createCollection();
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$max = 120;
$document = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents', [
@ -64,7 +64,7 @@ class AbuseTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'The Hulk',
],
@ -94,7 +94,7 @@ class AbuseTest extends Scope
{
$data = $this->createCollection();
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$max = 60;
for ($i = 0; $i <= $max + 1; $i++) {
@ -103,7 +103,7 @@ class AbuseTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'The Hulk',
],
@ -232,7 +232,7 @@ class AbuseTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
@ -258,7 +258,7 @@ class AbuseTest extends Scope
return [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'tableId' => $collectionId,
];
}

View file

@ -416,8 +416,8 @@ class UsageTest extends Scope
$requestsTotal = $data['requestsTotal'];
$databasesTotal = 0;
$collectionsTotal = 0;
$documentsTotal = 0;
$tablesTotal = 0;
$rowsTotal = 0;
for ($i = 0; $i < self::CREATE; $i++) {
$name = uniqid() . ' database';
@ -470,7 +470,7 @@ class UsageTest extends Scope
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()),
[
'collectionId' => 'unique()',
'tableId' => 'unique()',
'name' => $name,
'documentSecurity' => false,
'permissions' => [
@ -486,7 +486,7 @@ class UsageTest extends Scope
$this->assertNotEmpty($response['body']['$id']);
$requestsTotal += 1;
$collectionsTotal += 1;
$tablesTotal += 1;
$collectionId = $response['body']['$id'];
@ -501,7 +501,7 @@ class UsageTest extends Scope
$this->assertEmpty($response['body']);
$collectionsTotal -= 1;
$tablesTotal -= 1;
$requestsTotal += 1;
}
}
@ -537,7 +537,7 @@ class UsageTest extends Scope
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()),
[
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => ['name' => $name]
]
);
@ -546,7 +546,7 @@ class UsageTest extends Scope
$this->assertNotEmpty($response['body']['$id']);
$requestsTotal += 1;
$documentsTotal += 1;
$rowsTotal += 1;
$documentId = $response['body']['$id'];
@ -561,18 +561,18 @@ class UsageTest extends Scope
$this->assertEmpty($response['body']);
$documentsTotal -= 1;
$rowsTotal -= 1;
$requestsTotal += 1;
}
}
return array_merge($data, [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'tableId' => $collectionId,
'requestsTotal' => $requestsTotal,
'databasesTotal' => $databasesTotal,
'collectionsTotal' => $collectionsTotal,
'documentsTotal' => $documentsTotal,
'tablesTotal' => $tablesTotal,
'rowsTotal' => $rowsTotal,
]);
}
@ -581,11 +581,11 @@ class UsageTest extends Scope
public function testDatabaseStats(array $data): array
{
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$requestsTotal = $data['requestsTotal'];
$databasesTotal = $data['databasesTotal'];
$collectionsTotal = $data['collectionsTotal'];
$documentsTotal = $data['documentsTotal'];
$tablesTotal = $data['tablesTotal'];
$rowsTotal = $data['rowsTotal'];
sleep(self::WAIT);
@ -606,7 +606,7 @@ class UsageTest extends Scope
$this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);
$this->validateDates($response['body']['requests']);
$this->assertEquals($databasesTotal, $response['body']['databasesTotal']);
$this->assertEquals($documentsTotal, $response['body']['documentsTotal']);
$this->assertEquals($rowsTotal, $response['body']['rowsTotal']);
$response = $this->client->call(
Client::METHOD_GET,
@ -616,10 +616,10 @@ class UsageTest extends Scope
$this->assertEquals($databasesTotal, $response['body']['databases'][array_key_last($response['body']['databases'])]['value']);
$this->validateDates($response['body']['databases']);
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
$this->validateDates($response['body']['collections']);
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
$this->validateDates($response['body']['documents']);
$this->assertEquals($tablesTotal, $response['body']['tables'][array_key_last($response['body']['tables'])]['value']);
$this->validateDates($response['body']['tables']);
$this->assertEquals($rowsTotal, $response['body']['rows'][array_key_last($response['body']['rows'])]['value']);
$this->validateDates($response['body']['rows']);
$response = $this->client->call(
Client::METHOD_GET,
@ -627,11 +627,11 @@ class UsageTest extends Scope
$this->getConsoleHeaders()
);
$this->assertEquals($collectionsTotal, $response['body']['collections'][array_key_last($response['body']['collections'])]['value']);
$this->validateDates($response['body']['collections']);
$this->assertEquals($tablesTotal, $response['body']['tables'][array_key_last($response['body']['tables'])]['value']);
$this->validateDates($response['body']['tables']);
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
$this->validateDates($response['body']['documents']);
$this->assertEquals($rowsTotal, $response['body']['rows'][array_key_last($response['body']['rows'])]['value']);
$this->validateDates($response['body']['rows']);
$response = $this->client->call(
Client::METHOD_GET,
@ -639,8 +639,8 @@ class UsageTest extends Scope
$this->getConsoleHeaders()
);
$this->assertEquals($documentsTotal, $response['body']['documents'][array_key_last($response['body']['documents'])]['value']);
$this->validateDates($response['body']['documents']);
$this->assertEquals($rowsTotal, $response['body']['rows'][array_key_last($response['body']['rows'])]['value']);
$this->validateDates($response['body']['rows']);
return $data;
}

View file

@ -51,7 +51,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'documentSecurity' => true,
'permissions' => [
@ -67,7 +67,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Actors',
'documentSecurity' => true,
'permissions' => [
@ -148,7 +148,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America',
],
@ -275,7 +275,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $data['actorsId'],
'relatedTableId' => $data['actorsId'],
'type' => 'oneToMany',
'twoWay' => true,
'key' => 'starringActors',
@ -417,7 +417,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'patch',
'documentSecurity' => true,
'permissions' => [
@ -488,7 +488,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Players',
'documentSecurity' => true,
'permissions' => [
@ -540,7 +540,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Response Models',
// 'permissions' missing on purpose to make sure it's optional
'documentSecurity' => true,
@ -654,7 +654,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $data['actorsId'],
'relatedTableId' => $data['actorsId'],
'type' => 'oneToMany',
'twoWay' => true,
'key' => 'relationship',
@ -1463,7 +1463,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
@ -1484,7 +1484,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Spider-Man: Far From Home',
'releaseYear' => 2019,
@ -1507,7 +1507,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Spider-Man: Homecoming',
'releaseYear' => 2017,
@ -1530,7 +1530,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'releaseYear' => 2020, // Missing title, expect an 400 error
],
@ -1542,7 +1542,7 @@ trait DatabasesBase
]);
$this->assertEquals(201, $document1['headers']['status-code']);
$this->assertEquals($data['moviesId'], $document1['body']['$collectionId']);
$this->assertEquals($data['moviesId'], $document1['body']['$tableId']);
$this->assertArrayNotHasKey('$collection', $document1['body']);
$this->assertEquals($databaseId, $document1['body']['$databaseId']);
$this->assertEquals($document1['body']['title'], 'Captain America');
@ -1555,7 +1555,7 @@ trait DatabasesBase
$this->assertEquals($document1['body']['birthDay'], '1975-06-12T12:12:55.000+00:00');
$this->assertEquals(201, $document2['headers']['status-code']);
$this->assertEquals($data['moviesId'], $document2['body']['$collectionId']);
$this->assertEquals($data['moviesId'], $document2['body']['$tableId']);
$this->assertArrayNotHasKey('$collection', $document2['body']);
$this->assertEquals($databaseId, $document2['body']['$databaseId']);
$this->assertEquals($document2['body']['title'], 'Spider-Man: Far From Home');
@ -1572,7 +1572,7 @@ trait DatabasesBase
$this->assertEquals($document2['body']['integers'][1], 60);
$this->assertEquals(201, $document3['headers']['status-code']);
$this->assertEquals($data['moviesId'], $document3['body']['$collectionId']);
$this->assertEquals($data['moviesId'], $document3['body']['$tableId']);
$this->assertArrayNotHasKey('$collection', $document3['body']);
$this->assertEquals($databaseId, $document3['body']['$databaseId']);
$this->assertEquals($document3['body']['title'], 'Spider-Man: Homecoming');
@ -1621,7 +1621,8 @@ trait DatabasesBase
$this->assertCount(3, $documents['body']['rows']);
foreach ($documents['body']['rows'] as $document) {
$this->assertEquals($data['moviesId'], $document['$collectionId']);
print_r($document);
$this->assertEquals($data['moviesId'], $document['$tableId']);
$this->assertArrayNotHasKey('$collection', $document);
$this->assertEquals($databaseId, $document['$databaseId']);
}
@ -1655,7 +1656,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Dummy',
'releaseYear' => 1944,
@ -1696,14 +1697,14 @@ trait DatabasesBase
{
$databaseId = $data['databaseId'];
foreach ($data['rows'] as $document) {
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $document['$collectionId'] . '/documents/' . $document['$id'], array_merge([
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $document['$tableId'] . '/documents/' . $document['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals($response['body']['$id'], $document['$id']);
$this->assertEquals($document['$collectionId'], $response['body']['$collectionId']);
$this->assertEquals($document['$tableId'], $response['body']['$tableId']);
$this->assertArrayNotHasKey('$collection', $response['body']);
$this->assertEquals($document['$databaseId'], $response['body']['$databaseId']);
$this->assertEquals($response['body']['title'], $document['title']);
@ -1723,7 +1724,7 @@ trait DatabasesBase
$databaseId = $data['databaseId'];
$document = $data['rows'][0];
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $document['$collectionId'] . '/documents/' . $document['$id'], array_merge([
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $document['$tableId'] . '/documents/' . $document['$id'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
@ -2287,7 +2288,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Thor: Ragnaroc',
'releaseYear' => 2017,
@ -2305,7 +2306,7 @@ trait DatabasesBase
$id = $document['body']['$id'];
$this->assertEquals(201, $document['headers']['status-code']);
$this->assertEquals($data['moviesId'], $document['body']['$collectionId']);
$this->assertEquals($data['moviesId'], $document['body']['$tableId']);
$this->assertArrayNotHasKey('$collection', $document['body']);
$this->assertEquals($databaseId, $document['body']['$databaseId']);
$this->assertEquals($document['body']['title'], 'Thor: Ragnaroc');
@ -2333,7 +2334,7 @@ trait DatabasesBase
$this->assertEquals(200, $document['headers']['status-code']);
$this->assertEquals($document['body']['$id'], $id);
$this->assertEquals($data['moviesId'], $document['body']['$collectionId']);
$this->assertEquals($data['moviesId'], $document['body']['$tableId']);
$this->assertArrayNotHasKey('$collection', $document['body']);
$this->assertEquals($databaseId, $document['body']['$databaseId']);
$this->assertEquals($document['body']['title'], 'Thor: Ragnarok');
@ -2350,7 +2351,7 @@ trait DatabasesBase
$id = $document['body']['$id'];
$this->assertEquals(200, $document['headers']['status-code']);
$this->assertEquals($data['moviesId'], $document['body']['$collectionId']);
$this->assertEquals($data['moviesId'], $document['body']['$tableId']);
$this->assertArrayNotHasKey('$collection', $document['body']);
$this->assertEquals($databaseId, $document['body']['$databaseId']);
$this->assertEquals($document['body']['title'], 'Thor: Ragnarok');
@ -2413,7 +2414,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Thor: Ragnarok',
'releaseYear' => 2017,
@ -2474,7 +2475,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'invalidDocumentStructure',
'permissions' => [
Permission::create(Role::any()),
@ -2692,7 +2693,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'email' => 'user@example.com',
],
@ -2707,7 +2708,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'enum' => 'yes',
],
@ -2722,7 +2723,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'ip' => '1.1.1.1',
],
@ -2737,7 +2738,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'url' => 'http://www.example.com',
],
@ -2752,7 +2753,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'range' => 3,
],
@ -2767,7 +2768,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'floatRange' => 1.4,
],
@ -2782,7 +2783,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'probability' => 0.99999,
],
@ -2797,7 +2798,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'upperBound' => 8,
],
@ -2812,7 +2813,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'lowerBound' => 8,
],
@ -2841,7 +2842,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'email' => 'user@@example.com',
],
@ -2856,7 +2857,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'enum' => 'badEnum',
],
@ -2871,7 +2872,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'ip' => '1.1.1.1.1',
],
@ -2886,7 +2887,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'url' => 'example...com',
],
@ -2901,7 +2902,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'range' => 11,
],
@ -2916,7 +2917,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'floatRange' => 2.5,
],
@ -2931,7 +2932,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'probability' => 1.1,
],
@ -2946,7 +2947,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'upperBound' => 11,
],
@ -2961,7 +2962,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'lowerBound' => 3,
],
@ -2976,7 +2977,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'birthDay' => '2020-10-10 27:30:10+01:00',
],
@ -3015,7 +3016,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
@ -3145,7 +3146,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'enforceCollectionAndDocumentPermissions',
'documentSecurity' => true,
'permissions' => [
@ -3200,7 +3201,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
@ -3217,7 +3218,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
@ -3234,7 +3235,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
@ -3338,7 +3339,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'enforceCollectionPermissions',
'permissions' => [
Permission::read(Role::user($user)),
@ -3388,7 +3389,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
@ -3405,7 +3406,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
@ -3422,7 +3423,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'attribute' => 'one',
],
@ -3541,7 +3542,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
@ -3564,7 +3565,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America 5',
'releaseYear' => 1944,
@ -3587,7 +3588,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America',
'releaseYear' => 1944,
@ -3623,7 +3624,7 @@ trait DatabasesBase
];
$document = $this->client->call(Client::METHOD_POST, '/databases/' . $data['databaseId'] . '/collections/' . $data['moviesId'] . '/documents', $headers, [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Creation Date Test',
'releaseYear' => 2000
@ -3691,7 +3692,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::create(Role::user(ID::custom($this->getUser()['$id']))),
@ -3728,7 +3729,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America',
],
@ -3802,7 +3803,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Boolean'
]);
@ -3847,7 +3848,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'person',
'tableId' => 'person',
'name' => 'person',
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
@ -3865,7 +3866,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'library',
'tableId' => 'library',
'name' => 'library',
'permissions' => [
Permission::read(Role::user($this->getUser()['$id'])),
@ -3894,7 +3895,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => 'library',
'relatedTableId' => 'library',
'type' => Database::RELATION_ONE_TO_ONE,
'key' => 'library',
'twoWay' => true,
@ -3957,7 +3958,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'library' => [
'$id' => 'library1',
@ -3981,7 +3982,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'library' => [
'libraryName' => 'Library 2',
@ -4000,8 +4001,8 @@ trait DatabasesBase
$this->assertEquals($databaseId, $person1['body']['$databaseId']);
$this->assertEquals($databaseId, $person1['body']['library']['$databaseId']);
$this->assertEquals($person['body']['$id'], $person1['body']['$collectionId']);
$this->assertEquals($library['body']['$id'], $person1['body']['library']['$collectionId']);
$this->assertEquals($person['body']['$id'], $person1['body']['$tableId']);
$this->assertEquals($library['body']['$id'], $person1['body']['library']['$tableId']);
$this->assertArrayNotHasKey('$collection', $person1['body']);
$this->assertArrayNotHasKey('$collection', $person1['body']['library']);
@ -4092,7 +4093,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => 'library',
'relatedTableId' => 'library',
'type' => Database::RELATION_ONE_TO_MANY,
'twoWay' => true,
'key' => 'libraries',
@ -4141,7 +4142,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'person10',
'rowId' => 'person10',
'data' => [
'fullName' => 'Stevie Wonder',
'libraries' => [
@ -4237,7 +4238,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Albums',
'documentSecurity' => true,
'permissions' => [
@ -4263,7 +4264,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Artists',
'documentSecurity' => true,
'permissions' => [
@ -4289,7 +4290,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $artists['body']['$id'],
'relatedTableId' => $artists['body']['$id'],
'type' => Database::RELATION_MANY_TO_ONE,
'twoWay' => true,
'key' => 'artist',
@ -4318,7 +4319,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'album1',
'rowId' => 'album1',
'permissions' => $permissions,
'data' => [
'name' => 'Album 1',
@ -4381,7 +4382,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Sports',
'documentSecurity' => true,
'permissions' => [
@ -4407,7 +4408,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Players',
'documentSecurity' => true,
'permissions' => [
@ -4433,7 +4434,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $players['body']['$id'],
'relatedTableId' => $players['body']['$id'],
'type' => Database::RELATION_MANY_TO_MANY,
'twoWay' => true,
'key' => 'players',
@ -4463,7 +4464,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => 'sport1',
'rowId' => 'sport1',
'permissions' => $permissions,
'data' => [
'name' => 'Sport 1',
@ -4562,7 +4563,7 @@ trait DatabasesBase
$this->assertEquals(null, $response['body']['rows'][0]['fullName']);
$this->assertArrayNotHasKey("libraries", $response['body']['rows'][0]);
$this->assertArrayNotHasKey('$databaseId', $response['body']['rows'][0]);
$this->assertArrayNotHasKey('$collectionId', $response['body']['rows'][0]);
$this->assertArrayNotHasKey('$tableId', $response['body']['rows'][0]);
}
/**
@ -4583,7 +4584,7 @@ trait DatabasesBase
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertArrayNotHasKey('libraries', $response['body']['rows'][0]);
$this->assertArrayNotHasKey('$databaseId', $response['body']['rows'][0]);
$this->assertArrayNotHasKey('$collectionId', $response['body']['rows'][0]);
$this->assertArrayNotHasKey('$tableId', $response['body']['rows'][0]);
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $data['databaseId'] . '/collections/' . $data['personCollection'] . '/documents', array_merge([
'content-type' => 'application/json',
@ -4597,7 +4598,7 @@ trait DatabasesBase
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertArrayHasKey('libraries', $document);
$this->assertArrayNotHasKey('$databaseId', $document);
$this->assertArrayNotHasKey('$collectionId', $document);
$this->assertArrayNotHasKey('$tableId', $document);
$response = $this->client->call(Client::METHOD_GET, '/databases/' . $data['databaseId'] . '/collections/' . $data['personCollection'] . '/documents/' . $document['$id'], array_merge([
'content-type' => 'application/json',
@ -4641,7 +4642,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'USA Presidents',
'documentSecurity' => true,
'permissions' => [
@ -4683,7 +4684,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'first_name' => 'Donald',
'last_name' => 'Trump',
@ -4698,7 +4699,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'first_name' => 'George',
'last_name' => 'Bush',
@ -4713,7 +4714,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'first_name' => 'Joe',
'last_name' => 'Biden',
@ -4764,7 +4765,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Collection1',
'documentSecurity' => true,
'permissions' => [
@ -4778,7 +4779,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Collection2',
'documentSecurity' => true,
'permissions' => [
@ -4815,7 +4816,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2,
'relatedTableId' => $collection2,
'type' => Database::RELATION_ONE_TO_MANY,
'twoWay' => true,
'key' => 'collection2'
@ -4827,7 +4828,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id']
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'name' => 'Document 1',
'collection2' => [
@ -4860,7 +4861,7 @@ trait DatabasesBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Slow Queries',
'documentSecurity' => true,
'permissions' => [
@ -4893,7 +4894,7 @@ trait DatabasesBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'longtext' => file_get_contents(__DIR__ . '/../../../resources/longtext.txt'),
],

View file

@ -38,7 +38,7 @@ class DatabasesConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
@ -69,7 +69,7 @@ class DatabasesConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'TvShows',
'permissions' => [
Permission::read(Role::any()),

View file

@ -40,7 +40,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'documentSecurity' => true,
'permissions' => [
@ -73,7 +73,7 @@ class DatabasesCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America',
],
@ -95,7 +95,7 @@ class DatabasesCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Captain America',
],
@ -138,7 +138,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('permissionCheck'),
'tableId' => ID::custom('permissionCheck'),
'name' => 'permissionCheck',
'permissions' => [],
'documentSecurity' => true,
@ -166,7 +166,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => ID::custom('permissionCheckDocument'),
'rowId' => ID::custom('permissionCheckDocument'),
'data' => [
'name' => 'AppwriteBeginner',
],
@ -247,7 +247,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'level1',
'documentSecurity' => false,
'permissions' => [
@ -264,7 +264,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'level2',
'documentSecurity' => false,
'permissions' => [
@ -283,7 +283,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2['body']['$id'],
'relatedTableId' => $collection2['body']['$id'],
'type' => 'oneToMany',
'twoWay' => true,
'onDelete' => 'cascade',
@ -335,7 +335,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'c1',
'documentSecurity' => false,
'permissions' => [
@ -351,7 +351,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'c2',
'documentSecurity' => false,
'permissions' => [
@ -369,7 +369,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2['body']['$id'],
'relatedTableId' => $collection2['body']['$id'],
'type' => Database::RELATION_ONE_TO_ONE,
'twoWay' => false,
'onDelete' => 'cascade',
@ -387,7 +387,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2['body']['$id'],
'relatedTableId' => $collection2['body']['$id'],
'type' => Database::RELATION_ONE_TO_MANY,
'twoWay' => false,
'onDelete' => 'cascade',
@ -406,7 +406,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2['body']['$id'],
'relatedTableId' => $collection2['body']['$id'],
'type' => Database::RELATION_ONE_TO_MANY,
'twoWay' => false,
'onDelete' => 'cascade',
@ -424,7 +424,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2['body']['$id'],
'relatedTableId' => $collection2['body']['$id'],
'type' => Database::RELATION_ONE_TO_MANY,
'twoWay' => false,
'onDelete' => 'cascade',
@ -442,7 +442,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2['body']['$id'],
'relatedTableId' => $collection2['body']['$id'],
'type' => Database::RELATION_MANY_TO_MANY,
'twoWay' => true,
'onDelete' => 'setNull',
@ -461,7 +461,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2['body']['$id'],
'relatedTableId' => $collection2['body']['$id'],
'type' => Database::RELATION_MANY_TO_MANY,
'twoWay' => true,
'onDelete' => 'setNull',
@ -495,7 +495,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('collection1'),
'tableId' => ID::custom('collection1'),
'name' => ID::custom('collection1'),
'documentSecurity' => false,
'permissions' => [
@ -511,7 +511,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('collection2'),
'tableId' => ID::custom('collection2'),
'name' => ID::custom('collection2'),
'documentSecurity' => false,
'permissions' => [
@ -524,7 +524,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('collection3'),
'tableId' => ID::custom('collection3'),
'name' => ID::custom('collection3'),
'documentSecurity' => false,
'permissions' => [
@ -539,7 +539,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('collection4'),
'tableId' => ID::custom('collection4'),
'name' => ID::custom('collection4'),
'documentSecurity' => false,
'permissions' => [
@ -552,7 +552,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('collection5'),
'tableId' => ID::custom('collection5'),
'name' => ID::custom('collection5'),
'documentSecurity' => false,
'permissions' => [
@ -568,7 +568,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2['body']['$id'],
'relatedTableId' => $collection2['body']['$id'],
'type' => 'oneToOne',
'twoWay' => false,
'onDelete' => 'setNull',
@ -581,7 +581,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection3['body']['$id'],
'relatedTableId' => $collection3['body']['$id'],
'type' => 'oneToOne',
'twoWay' => false,
'onDelete' => 'setNull',
@ -594,7 +594,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection4['body']['$id'],
'relatedTableId' => $collection4['body']['$id'],
'type' => 'oneToOne',
'twoWay' => false,
'onDelete' => 'setNull',
@ -607,7 +607,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection5['body']['$id'],
'relatedTableId' => $collection5['body']['$id'],
'type' => 'oneToOne',
'twoWay' => false,
'onDelete' => 'setNull',
@ -681,7 +681,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => ID::custom($collection1['body']['$id']),
'rowId' => ID::custom($collection1['body']['$id']),
'data' => [
'Title' => 'Captain America',
$collection2['body']['$id'] => [
@ -709,7 +709,7 @@ class DatabasesCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::custom($collection1['body']['$id']),
'rowId' => ID::custom($collection1['body']['$id']),
'data' => [
'Title' => 'Captain America',
$collection2['body']['$id'] => [
@ -739,7 +739,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('collection3'),
'tableId' => ID::custom('collection3'),
'name' => ID::custom('collection3'),
'documentSecurity' => false,
'permissions' => [
@ -814,7 +814,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('collection3'),
'tableId' => ID::custom('collection3'),
'name' => ID::custom('collection3'),
'documentSecurity' => false,
'permissions' => [
@ -830,7 +830,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('collection2'),
'tableId' => ID::custom('collection2'),
'name' => ID::custom('collection2'),
'documentSecurity' => false,
'permissions' => [
@ -847,7 +847,7 @@ class DatabasesCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => ID::custom('collection3Doc1'),
'rowId' => ID::custom('collection3Doc1'),
'data' => [
'Rating' => '20'
]

View file

@ -358,7 +358,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Test 1',
'collectionId' => ID::custom('first'),
'tableId' => ID::custom('first'),
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
@ -374,7 +374,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Test 2',
'collectionId' => ID::custom('second'),
'tableId' => ID::custom('second'),
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
@ -579,7 +579,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Test 1',
'collectionId' => ID::custom('first'),
'tableId' => ID::custom('first'),
'permissions' => [
Permission::read(Role::any()),
Permission::create(Role::any()),
@ -592,7 +592,7 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals(409, $response['headers']['status-code']);
return [
'databaseId' => $databaseId,
'collectionId' => $test1['body']['$id'],
'tableId' => $test1['body']['$id'],
];
}
@ -602,7 +602,7 @@ class DatabasesCustomServerTest extends Scope
public function testGetCollection(array $data): void
{
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$collection = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
@ -622,7 +622,7 @@ class DatabasesCustomServerTest extends Scope
public function testUpdateCollection(array $data)
{
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$collection = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $collectionId, array_merge([
'content-type' => 'application/json',
@ -657,7 +657,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Encrypted Actors Data',
'permissions' => [
Permission::read(Role::any()),
@ -719,7 +719,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'firstName' => 'Jonah',
'lastName' => 'Jameson',
@ -767,7 +767,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::any()),
@ -820,7 +820,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'firstName' => 'lorem',
'lastName' => 'ipsum',
@ -898,7 +898,7 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals($collection['body']['columns'][1]['key'], $lastName['body']['key']);
return [
'collectionId' => $actors['body']['$id'],
'tableId' => $actors['body']['$id'],
'key' => $index['body']['key'],
'databaseId' => $databaseId
];
@ -910,7 +910,7 @@ class DatabasesCustomServerTest extends Scope
public function testDeleteIndex($data): array
{
$databaseId = $data['databaseId'];
$index = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['collectionId'] . '/indexes/' . $data['key'], array_merge([
$index = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['tableId'] . '/indexes/' . $data['key'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -921,7 +921,7 @@ class DatabasesCustomServerTest extends Scope
// Wait for database worker to finish deleting index
sleep(2);
$collection = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['collectionId'], array_merge([
$collection = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['tableId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -938,7 +938,7 @@ class DatabasesCustomServerTest extends Scope
public function testDeleteIndexOnDeleteAttribute($data)
{
$databaseId = $data['databaseId'];
$attribute1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['collectionId'] . '/attributes/string', array_merge([
$attribute1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['tableId'] . '/attributes/string', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -948,7 +948,7 @@ class DatabasesCustomServerTest extends Scope
'required' => true,
]);
$attribute2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['collectionId'] . '/attributes/string', array_merge([
$attribute2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['tableId'] . '/attributes/string', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -965,7 +965,7 @@ class DatabasesCustomServerTest extends Scope
sleep(2);
$index1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['collectionId'] . '/indexes', array_merge([
$index1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['tableId'] . '/indexes', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -976,7 +976,7 @@ class DatabasesCustomServerTest extends Scope
'orders' => ['ASC', 'ASC'],
]);
$index2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['collectionId'] . '/indexes', array_merge([
$index2 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $data['tableId'] . '/indexes', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -994,7 +994,7 @@ class DatabasesCustomServerTest extends Scope
sleep(2);
// Expected behavior: deleting attribute2 will cause index2 to be dropped, and index1 rebuilt with a single key
$deleted = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['collectionId'] . '/attributes/' . $attribute2['body']['key'], array_merge([
$deleted = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['tableId'] . '/attributes/' . $attribute2['body']['key'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -1005,7 +1005,7 @@ class DatabasesCustomServerTest extends Scope
// wait for database worker to complete
sleep(2);
$collection = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['collectionId'], array_merge([
$collection = $this->client->call(Client::METHOD_GET, '/databases/' . $databaseId . '/collections/' . $data['tableId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -1020,7 +1020,7 @@ class DatabasesCustomServerTest extends Scope
$this->assertEquals($attribute1['body']['key'], $collection['body']['indexes'][0]['columns'][0]);
// Delete attribute
$deleted = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['collectionId'] . '/attributes/' . $attribute1['body']['key'], array_merge([
$deleted = $this->client->call(Client::METHOD_DELETE, '/databases/' . $databaseId . '/collections/' . $data['tableId'] . '/attributes/' . $attribute1['body']['key'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
@ -1050,7 +1050,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'TestCleanupDuplicateIndexOnDeleteAttribute',
'permissions' => [
Permission::read(Role::any()),
@ -1163,14 +1163,14 @@ class DatabasesCustomServerTest extends Scope
public function testDeleteCollection($data)
{
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
// Add Documents to the collection
$document1 = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'firstName' => 'Tom',
'lastName' => 'Holland',
@ -1186,7 +1186,7 @@ class DatabasesCustomServerTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'firstName' => 'Samuel',
'lastName' => 'Jackson',
@ -1249,7 +1249,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Collection1',
'documentSecurity' => false,
'permissions' => [],
@ -1260,7 +1260,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Collection2',
'documentSecurity' => false,
'permissions' => [],
@ -1274,7 +1274,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
]), [
'relatedCollectionId' => $collection2,
'relatedTableId' => $collection2,
'type' => Database::RELATION_MANY_TO_ONE,
'twoWay' => false,
'key' => 'collection2'
@ -1318,7 +1318,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('attributeRowWidthLimit'),
'tableId' => ID::custom('attributeRowWidthLimit'),
'name' => 'attributeRowWidthLimit',
'permissions' => [
Permission::read(Role::any()),
@ -1384,7 +1384,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('testLimitException'),
'tableId' => ID::custom('testLimitException'),
'name' => 'testLimitException',
'permissions' => [
Permission::read(Role::any()),
@ -1508,7 +1508,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::custom('updateAttributes'),
'tableId' => ID::custom('updateAttributes'),
'name' => 'updateAttributes'
]);
@ -1642,7 +1642,7 @@ class DatabasesCustomServerTest extends Scope
return [
'databaseId' => $databaseId,
'collectionId' => $collectionId
'tableId' => $collectionId
];
}
@ -1653,7 +1653,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'string';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/string/' . $key, array_merge([
'content-type' => 'application/json',
@ -1795,7 +1795,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'email';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/email/' . $key, array_merge([
'content-type' => 'application/json',
@ -1938,7 +1938,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'ip';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/ip/' . $key, array_merge([
'content-type' => 'application/json',
@ -2080,7 +2080,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'url';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/url/' . $key, array_merge([
'content-type' => 'application/json',
@ -2222,7 +2222,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'integer';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/integer/' . $key, array_merge([
'content-type' => 'application/json',
@ -2483,7 +2483,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'float';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/float/' . $key, array_merge([
'content-type' => 'application/json',
@ -2744,7 +2744,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'boolean';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/boolean/' . $key, array_merge([
'content-type' => 'application/json',
@ -2886,7 +2886,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'datetime';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/datetime/' . $key, array_merge([
'content-type' => 'application/json',
@ -3028,7 +3028,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'enum';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$update = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $collectionId . '/attributes/enum/' . $key, array_merge([
'content-type' => 'application/json',
@ -3244,7 +3244,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'string';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$document = $this->client->call(
Client::METHOD_POST,
@ -3255,7 +3255,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]),
[
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'string' => 'string'
],
@ -3287,7 +3287,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]),
[
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'string' => str_repeat('a', 2048)
],
@ -3373,7 +3373,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]),
[
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'string' => str_repeat('a', 10)
],
@ -3408,7 +3408,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]),
[
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'string' => str_repeat('a', 11)
],
@ -3426,7 +3426,7 @@ class DatabasesCustomServerTest extends Scope
public function testAttributeUpdateNotFound(array $data)
{
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$attributes = [
'string' => [
@ -3514,7 +3514,7 @@ class DatabasesCustomServerTest extends Scope
{
$key = 'string';
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
// Create document to test against
$document = $this->client->call(
@ -3526,7 +3526,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]),
[
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'string' => 'string'
],
@ -3578,7 +3578,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]),
[
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'new_string' => 'string'
],
@ -3600,7 +3600,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]),
[
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'string' => 'string'
],
@ -3630,7 +3630,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'collection1',
'tableId' => 'collection1',
'name' => 'level1',
'documentSecurity' => false,
'permissions' => [
@ -3646,7 +3646,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => 'collection2',
'tableId' => 'collection2',
'name' => 'level2',
'documentSecurity' => false,
'permissions' => [
@ -3684,7 +3684,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2Id,
'relatedTableId' => $collection2Id,
'type' => 'oneToMany',
'twoWay' => true,
'onDelete' => 'cascade',
@ -3712,7 +3712,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'level2' => [[
'$id' => 'unique()',
@ -3794,7 +3794,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2Id,
'relatedTableId' => $collection2Id,
'type' => 'oneToOne',
'twoWay' => true,
'onDelete' => 'cascade',
@ -3822,7 +3822,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'level2' => [
'$id' => 'unique()',
@ -3904,7 +3904,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2Id,
'relatedTableId' => $collection2Id,
'type' => 'manyToOne',
'twoWay' => true,
'onDelete' => 'cascade',
@ -3932,7 +3932,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'level2' => [
'$id' => 'unique()',
@ -4014,7 +4014,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'relatedCollectionId' => $collection2Id,
'relatedTableId' => $collection2Id,
'type' => 'manyToOne',
'twoWay' => true,
'onDelete' => 'cascade',
@ -4042,7 +4042,7 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'documentId' => 'unique()',
'rowId' => 'unique()',
'data' => [
'level2' => [
'$id' => 'unique()',

View file

@ -32,7 +32,7 @@ class DatabasesPermissionsGuestTest extends Scope
$databaseId = $database['body']['$id'];
$publicMovies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
@ -42,7 +42,7 @@ class DatabasesPermissionsGuestTest extends Scope
],
]);
$privateMovies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'permissions' => [],
'documentSecurity' => true,
@ -94,14 +94,14 @@ class DatabasesPermissionsGuestTest extends Scope
$databaseId = $data['databaseId'];
$publicResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $publicCollectionId . '/documents', $this->getServerHeader(), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
'permissions' => $permissions,
]);
$privateResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $privateCollectionId . '/documents', $this->getServerHeader(), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@ -152,7 +152,7 @@ class DatabasesPermissionsGuestTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
]
@ -165,7 +165,7 @@ class DatabasesPermissionsGuestTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@ -175,7 +175,7 @@ class DatabasesPermissionsGuestTest extends Scope
// Create a document in private collection with API key so we can test that update and delete are also not allowed
$privateResponse = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $privateCollectionId . '/documents', $this->getServerHeader(), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@ -241,7 +241,7 @@ class DatabasesPermissionsGuestTest extends Scope
$databaseId = $database['body']['$id'];
$movies = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::create(Role::any()),
@ -263,7 +263,7 @@ class DatabasesPermissionsGuestTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Thor: Ragnarok',
],

View file

@ -125,7 +125,7 @@ class DatabasesPermissionsMemberTest extends Scope
$databaseId = $db['body']['$id'];
$public = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Movies',
'permissions' => [
Permission::read(Role::any()),
@ -146,7 +146,7 @@ class DatabasesPermissionsMemberTest extends Scope
$this->assertEquals(202, $response['headers']['status-code']);
$private = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Private Movies',
'permissions' => [
Permission::read(Role::users()),
@ -167,7 +167,7 @@ class DatabasesPermissionsMemberTest extends Scope
$this->assertEquals(202, $response['headers']['status-code']);
$doconly = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Document Only Movies',
'permissions' => [],
'documentSecurity' => true,
@ -203,7 +203,7 @@ class DatabasesPermissionsMemberTest extends Scope
$databaseId = $data['databaseId'];
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collections['public'] . '/documents', $this->getServerHeader(), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@ -212,7 +212,7 @@ class DatabasesPermissionsMemberTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collections['private'] . '/documents', $this->getServerHeader(), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@ -221,7 +221,7 @@ class DatabasesPermissionsMemberTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collections['doconly'] . '/documents', $this->getServerHeader(), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],

View file

@ -45,7 +45,7 @@ class DatabasesPermissionsTeamTest extends Scope
$this->assertEquals(201, $db['headers']['status-code']);
$collection1 = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => ID::custom('collection1'),
'tableId' => ID::custom('collection1'),
'name' => 'Collection 1',
'permissions' => [
Permission::read(Role::team($teams['team1']['$id'])),
@ -64,7 +64,7 @@ class DatabasesPermissionsTeamTest extends Scope
]);
$collection2 = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/collections', $this->getServerHeader(), [
'collectionId' => ID::custom('collection2'),
'tableId' => ID::custom('collection2'),
'name' => 'Collection 2',
'permissions' => [
Permission::read(Role::team($teams['team2']['$id'])),
@ -141,7 +141,7 @@ class DatabasesPermissionsTeamTest extends Scope
$this->createCollections($this->teams);
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/collections/' . $this->collections['collection1'] . '/documents', $this->getServerHeader(), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Lorem',
],
@ -149,7 +149,7 @@ class DatabasesPermissionsTeamTest extends Scope
$this->assertEquals(201, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_POST, '/databases/' . $this->databaseId . '/collections/' . $this->collections['collection2'] . '/documents', $this->getServerHeader(), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Ipsum',
],
@ -192,7 +192,7 @@ class DatabasesPermissionsTeamTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'cookie' => 'a_session_' . $this->getProject()['$id'] . '=' . $users[$user]['session'],
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'title' => 'Ipsum',
],

View file

@ -30,7 +30,7 @@ class AbuseTest extends Scope
{
$data = $this->createCollection();
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$projectId = $this->getProject()['$id'];
$query = $this->getQuery(self::$CREATE_ROW);
$max = 120;
@ -40,8 +40,8 @@ class AbuseTest extends Scope
'query' => $query,
'variables' => [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'documentId' => ID::unique(),
'tableId' => $collectionId,
'rowId' => ID::unique(),
'data' => [
'name' => 'John Doe',
],
@ -73,7 +73,7 @@ class AbuseTest extends Scope
'password' => 'password',
'databaseId' => 'database',
'databaseName' => 'database',
'collectionId' => 'collection',
'tableId' => 'collection',
'collectionName' => 'collection',
'collectionPermissions' => [
Permission::read(Role::users()),
@ -138,7 +138,7 @@ class AbuseTest extends Scope
'query' => $query,
'variables' => [
'databaseId' => $databaseId,
'collectionId' => 'actors',
'tableId' => 'actors',
'name' => 'Actors',
'documentSecurity' => false,
'permissions' => [
@ -161,7 +161,7 @@ class AbuseTest extends Scope
'query' => $query,
'variables' => [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'tableId' => $collectionId,
'key' => 'name',
'size' => 256,
'required' => true,
@ -178,7 +178,7 @@ class AbuseTest extends Scope
return [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'tableId' => $collectionId,
];
}
}

View file

@ -259,8 +259,8 @@ trait Base
// Fragments
public static string $FRAGMENT_COLUMNS = '
fragment attributeProperties on Attributes {
... on AttributeString {
fragment columnProperties on Columns {
... on ColumnString {
key
required
array
@ -268,7 +268,7 @@ trait Base
default
size
}
... on AttributeInteger {
... on ColumnInteger {
key
required
array
@ -277,7 +277,7 @@ trait Base
intMin: min
intMax: max
}
... on AttributeFloat {
... on ColumnFloat {
key
required
array
@ -286,35 +286,35 @@ trait Base
floatMin: min
floatMax: max
}
... on AttributeBoolean {
... on ColumnBoolean {
key
required
array
status
boolDefault:default
}
... on AttributeUrl {
... on ColumnUrl {
key
required
array
status
default
}
... on AttributeEmail {
... on ColumnEmail {
key
required
array
status
default
}
... on AttributeIp {
... on ColumnIp {
key
required
array
status
default
}
... on AttributeEnum {
... on ColumnEnum {
key
required
array
@ -322,7 +322,7 @@ trait Base
default
elements
}
... on AttributeDatetime {
... on ColumnDatetime {
key
required
array
@ -406,7 +406,7 @@ trait Base
return 'query listTables($databaseId: String!) {
databasesListTables(databaseId: $databaseId) {
total
collections {
tables {
_id
_permissions
documentSecurity
@ -527,7 +527,7 @@ trait Base
case self::$CREATE_RELATIONSHIP_COLUMN:
return 'mutation createRelationshipColumn($databaseId: String!, $tableId: String!, $relatedTableId: String!, $type: String!, $twoWay: Boolean, $key: String, $twoWayKey: String, $onDelete: String){
databasesCreateRelationshipColumn(databaseId: $databaseId, tableId: $tableId, relatedTableId: $relatedTableId, type: $type, twoWay: $twoWay, key: $key, twoWayKey: $twoWayKey, onDelete: $onDelete) {
relatedCollection
relatedTable
relationType
twoWay
key
@ -606,7 +606,7 @@ trait Base
case self::$UPDATE_RELATIONSHIP_COLUMN:
return 'mutation updateRelationshipColumn($databaseId: String!, $tableId: String!, $key: String!, $onDelete: String){
databasesUpdateRelationshipColumn(databaseId: $databaseId, tableId: $tableId, key: $key, onDelete: $onDelete) {
relatedCollection
relatedTable
relationType
twoWay
key
@ -651,15 +651,15 @@ trait Base
return 'query listColumns($databaseId: String!, $tableId: String!) {
databasesListColumns(databaseId: $databaseId, tableId: $tableId) {
total
attributes {
...attributeProperties
columns {
...columnProperties
}
}
}' . PHP_EOL . self::$FRAGMENT_COLUMNS;
case self::$GET_COLUMN:
return 'query getColumn($databaseId: String!, $tableId: String!, $key: String!) {
databasesGetColumn(databaseId: $databaseId, tableId: $tableId, key: $key) {
...attributeProperties
...columnProperties
}
}' . PHP_EOL . self::$FRAGMENT_COLUMNS;
case self::$DELETE_COLUMN:
@ -672,7 +672,7 @@ trait Base
return 'query getRow($databaseId: String!, $tableId: String!, $rowId: String!) {
databasesGetRow(databaseId: $databaseId, tableId: $tableId, rowId: $rowId) {
_id
_collectionId
_tableId
_permissions
data
}
@ -681,9 +681,9 @@ trait Base
return 'query listRows($databaseId: String!, $tableId: String!){
databasesListRows(databaseId: $databaseId, tableId: $tableId) {
total
documents {
rows {
_id
_collectionId
_tableId
_permissions
data
}
@ -693,7 +693,7 @@ trait Base
return 'mutation createRow($databaseId: String!, $tableId: String!, $rowId: String!, $data: Json!, $permissions: [String!]){
databasesCreateRow(databaseId: $databaseId, tableId: $tableId, rowId: $rowId, data: $data, permissions: $permissions) {
_id
_collectionId
_tableId
_permissions
}
}';
@ -760,7 +760,7 @@ trait Base
return 'mutation updateRow($databaseId: String!, $tableId: String!, $rowId: String!, $data: Json!, $permissions: [String!]){
databasesUpdateRow(databaseId: $databaseId, tableId: $tableId, rowId: $rowId, data: $data, permissions: $permissions) {
_id
_collectionId
_tableId
data
}
}';
@ -2259,8 +2259,8 @@ trait Base
_databaseId
name
documentSecurity
attributes {
...attributeProperties
columns {
...columnProperties
}
indexes {
key

View file

@ -445,7 +445,7 @@ trait MigrationsBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Test Collection',
]);
@ -536,7 +536,7 @@ trait MigrationsBase
return [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'tableId' => $collectionId,
];
}
@ -546,14 +546,14 @@ trait MigrationsBase
public function testAppwriteMigrationDatabasesDocument(array $data): void
{
$databaseId = $data['databaseId'];
$collectionId = $data['collectionId'];
$collectionId = $data['tableId'];
$document = $this->client->call(Client::METHOD_POST, '/databases/' . $databaseId . '/collections/' . $collectionId . '/documents', [
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey'],
], [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'name' => 'Test Document',
]
@ -927,7 +927,7 @@ trait MigrationsBase
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'name' => 'Test collection',
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
]);
$this->assertEquals(201, $response['headers']['status-code']);
@ -1131,7 +1131,7 @@ trait MigrationsBase
return [
'databaseId' => $databaseId,
'collectionId' => $collectionId,
'tableId' => $collectionId,
'migrationId' => $migration['body']['$id'],
];
}
@ -1142,7 +1142,7 @@ trait MigrationsBase
public function testImportSuccessful(array $response): void
{
$databaseId = $response['databaseId'];
$collectionId = $response['collectionId'];
$collectionId = $response['tableId'];
$migrationId = $response['migrationId'];
$documentsCountInCSV = 100;
@ -1176,7 +1176,7 @@ trait MigrationsBase
]);
$this->assertEquals(200, $documents['headers']['status-code']);
$this->assertIsArray($documents['body']['documents']);
$this->assertIsArray($documents['body']['rows']);
$this->assertIsNumeric($documents['body']['total']);
$this->assertEquals($documentsCountInCSV, $documents['body']['total']);
}

View file

@ -483,7 +483,7 @@ class ProjectsConsoleClientTest extends Scope
$this->assertIsArray($response['body']['requests']);
$this->assertIsArray($response['body']['network']);
$this->assertIsNumeric($response['body']['executionsTotal']);
$this->assertIsNumeric($response['body']['documentsTotal']);
$this->assertIsNumeric($response['body']['rowsTotal']);
$this->assertIsNumeric($response['body']['databasesTotal']);
$this->assertIsNumeric($response['body']['bucketsTotal']);
$this->assertIsNumeric($response['body']['usersTotal']);

View file

@ -162,7 +162,7 @@ class RealtimeConsoleClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::any()),
@ -272,7 +272,7 @@ class RealtimeConsoleClientTest extends Scope
], $this->getHeaders()), [
'key' => 'key_name',
'type' => 'key',
'attributes' => [
'columns' => [
'name',
],
]);

View file

@ -714,7 +714,7 @@ class RealtimeCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::create(Role::user($this->getUser()['$id'])),
@ -749,7 +749,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'name' => 'Chris Evans'
],
@ -795,7 +795,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'name' => 'Chris Evans 2'
],
@ -840,7 +840,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'name' => 'Bradley Cooper'
],
@ -934,7 +934,7 @@ class RealtimeCustomClientTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::any()),
@ -971,7 +971,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'name' => 'Chris Evans'
],
@ -1053,7 +1053,7 @@ class RealtimeCustomClientTest extends Scope
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'name' => 'Bradley Cooper'
],

View file

@ -61,7 +61,7 @@ trait WebhooksBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Actors',
'permissions' => [
Permission::read(Role::any()),
@ -211,7 +211,7 @@ trait WebhooksBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'firstName' => 'Chris',
'lastName' => 'Evans',
@ -254,7 +254,7 @@ trait WebhooksBase
$this->assertIsArray($webhook['data']['$permissions']);
$this->assertCount(3, $webhook['data']['$permissions']);
$data['documentId'] = $document['body']['$id'];
$data['rowId'] = $document['body']['$id'];
return $data;
}
@ -270,7 +270,7 @@ trait WebhooksBase
/**
* Test for SUCCESS
*/
$document = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $actorsId . '/documents/' . $data['documentId'], array_merge([
$document = $this->client->call(Client::METHOD_PATCH, '/databases/' . $databaseId . '/collections/' . $actorsId . '/documents/' . $data['rowId'], array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
@ -335,7 +335,7 @@ trait WebhooksBase
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'documentId' => ID::unique(),
'rowId' => ID::unique(),
'data' => [
'firstName' => 'Bradly',
'lastName' => 'Cooper',
@ -1119,7 +1119,7 @@ trait WebhooksBase
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'newCollection' . $i,
'permissions' => [
Permission::read(Role::any()),

View file

@ -79,7 +79,7 @@ class WebhooksCustomServerTest extends Scope
]), [
'key' => 'fullname',
'type' => 'key',
'attributes' => ['lastName', 'firstName'],
'columns' => ['lastName', 'firstName'],
'orders' => ['ASC', 'ASC'],
]);
@ -159,7 +159,7 @@ class WebhooksCustomServerTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
'x-appwrite-key' => $this->getProject()['apiKey']
]), [
'collectionId' => ID::unique(),
'tableId' => ID::unique(),
'name' => 'Demo',
'permissions' => [
Permission::read(Role::any()),