diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Create.php index 56c0753f08..7eb6a109c0 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Create.php @@ -23,7 +23,7 @@ class Create extends Action public static function getName(): string { - return 'createBooleanColumn'; + return 'createBooleanAttribute'; } protected function getResponseModel(): string|array diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Update.php index c8aa734570..9930ebdd8a 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Boolean/Update.php @@ -23,7 +23,7 @@ class Update extends Action public static function getName(): string { - return 'updateBooleanColumn'; + return 'updateBooleanAttribute'; } protected function getResponseModel(): string|array diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php index e04a89295b..3175efdd91 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/Get.php @@ -20,7 +20,7 @@ class Get extends Action public static function getName(): string { - return 'getColumn'; + return 'getAttribute'; } protected function getResponseModel(): string|array @@ -44,7 +44,7 @@ class Get extends Action $this ->setHttpMethod(self::HTTP_REQUEST_METHOD_GET) ->setHttpPath('/v1/databases/:databaseId/collections/:collectionId/attributes/:key') - ->desc('Get column') + ->desc('Get attribute') ->groups(['api', 'database']) ->label('scope', 'collections.read') ->label('resourceType', RESOURCE_TYPE_DATABASES) @@ -63,7 +63,7 @@ class Get extends Action )) ->param('databaseId', '', new UID(), 'Database ID.') ->param('tableId', '', new UID(), 'Table ID.') - ->param('key', '', new Key(), 'Column Key.') + ->param('key', '', new Key(), 'Attribute Key.') ->inject('response') ->inject('dbForProject') ->callback([$this, 'action']); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php index 29e8d1d6b9..fb77626021 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Attributes/XList.php @@ -7,7 +7,6 @@ use Appwrite\SDK\AuthType; use Appwrite\SDK\Method; use Appwrite\SDK\Response as SDKResponse; use Appwrite\Utopia\Database\Validator\Queries\Attributes; -use Appwrite\Utopia\Database\Validator\Queries\Columns; use Appwrite\Utopia\Response as UtopiaResponse; use Utopia\Database\Database; use Utopia\Database\Document; @@ -57,7 +56,7 @@ class XList extends Action )) ->param('databaseId', '', new UID(), 'Database ID.') ->param('collectionId', '', new UID(), 'Collection ID.') - ->param('queries', [], new Columns(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Attributes::ALLOWED_ATTRIBUTES), true) + ->param('queries', [], new Attributes(), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long. You may filter on the following attributes: ' . implode(', ', Attributes::ALLOWED_ATTRIBUTES), true) ->inject('response') ->inject('dbForProject') ->callback([$this, 'action']); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php index 6db7e802f3..c66f205a8c 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Create.php @@ -179,7 +179,7 @@ class Create extends Action $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($column) => $column->getAttribute('type') === Database::VAR_RELATIONSHIP + fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -261,7 +261,7 @@ class Create extends Action $relationships = \array_filter( $table->getAttribute('attributes', []), - fn ($column) => $column->getAttribute('type') === Database::VAR_RELATIONSHIP + fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -300,10 +300,10 @@ class Create extends Action ->dynamic($document, $this->getResponseModel()); $relationships = \array_map( - fn ($row) => $document->getAttribute('key'), + fn ($document) => $document->getAttribute('key'), \array_filter( $collection->getAttribute('attributes', []), - fn ($column) => $column->getAttribute('type') === Database::VAR_RELATIONSHIP + fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ) ); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php index f56ab40126..aa01eebcdf 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Get.php @@ -113,7 +113,7 @@ class Get extends Action $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($column) => $column->getAttribute('type') === Database::VAR_RELATIONSHIP + fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php index be009b9cd2..9b373c7e17 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php @@ -159,7 +159,7 @@ class Update extends Action $relationships = \array_filter( $collection->getAttribute('attributes', []), - fn ($column) => $column->getAttribute('type') === Database::VAR_RELATIONSHIP + fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -256,7 +256,7 @@ class Update extends Action $relationships = \array_filter( $table->getAttribute('attributes', []), - fn ($column) => $column->getAttribute('type') === Database::VAR_RELATIONSHIP + fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ); foreach ($relationships as $relationship) { @@ -290,7 +290,7 @@ class Update extends Action fn ($row) => $document->getAttribute('key'), \array_filter( $collection->getAttribute('attributes', []), - fn ($column) => $column->getAttribute('type') === Database::VAR_RELATIONSHIP + fn ($attribute) => $attribute->getAttribute('type') === Database::VAR_RELATIONSHIP ) ); diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php index 7b4f5855e2..57af51d908 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/XList.php @@ -212,12 +212,12 @@ class XList extends Action } if ($select) { - foreach ($documents as $row) { + foreach ($documents as $document) { if (!$hasDatabaseId) { - $row->removeAttribute('$databaseId'); + $document->removeAttribute('$databaseId'); } if (!$hasCollectionId) { - $row->removeAttribute('$collectionId'); + $document->removeAttribute('$collectionId'); } } } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php index fe21025740..6370a32a4c 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Create.php @@ -150,23 +150,23 @@ class Create extends Action throw new Exception($this->getParentUnknownException(), "Unknown $contextType: " . $attribute . ". Verify the $contextType name or create the $contextType."); } - $columnStatus = $oldAttributes[$attributeIndex]['status']; - $columnType = $oldAttributes[$attributeIndex]['type']; - $columnArray = $oldAttributes[$attributeIndex]['array'] ?? false; + $attributeStatus = $oldAttributes[$attributeIndex]['status']; + $attributeType = $oldAttributes[$attributeIndex]['type']; + $attributeArray = $oldAttributes[$attributeIndex]['array'] ?? false; - if ($columnType === Database::VAR_RELATIONSHIP) { + if ($attributeType === Database::VAR_RELATIONSHIP) { throw new Exception($this->getParentInvalidTypeException(), "Cannot create an index for a relationship $contextType: " . $oldAttributes[$attributeIndex]['key']); } // ensure attribute is available - if ($columnStatus !== 'available') { + if ($attributeStatus !== 'available') { $contextType = ucfirst($contextType); throw new Exception($this->getParentNotAvailableException(), "$contextType not available: " . $oldAttributes[$attributeIndex]['key']); } $lengths[$i] = null; - if ($columnArray === true) { + if ($attributeArray === true) { $lengths[$i] = Database::ARRAY_INDEX_LENGTH; $orders[$i] = null; } diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Create.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Create.php index 97ac92d559..77e31f4115 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Create.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Create.php @@ -22,6 +22,11 @@ class Create extends IndexCreate { use HTTP; + public static function getName(): string + { + return 'createColumnIndex'; + } + protected function getResponseModel(): string { return UtopiaResponse::MODEL_COLUMN_INDEX; @@ -44,7 +49,7 @@ class Create extends IndexCreate ->label('sdk', new Method( namespace: $this->getSdkNamespace(), group: $this->getSdkGroup(), - name: self::getName(), + name: 'createIndex', // getName needs to be different from parent action to avoid conflict in path name description: '/docs/references/databases/create-index.md', auth: [AuthType::KEY], responses: [ diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Delete.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Delete.php index 6a86a4767e..7a81942e32 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Delete.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Delete.php @@ -20,6 +20,11 @@ class Delete extends IndexDelete { use HTTP; + public static function getName(): string + { + return 'updateColumnIndex'; + } + /** * 1. `SDKResponse` uses `UtopiaResponse::MODEL_NONE`. * 2. But we later need the actual return type for events queue below! @@ -46,7 +51,7 @@ class Delete extends IndexDelete ->label('sdk', new Method( namespace: $this->getSdkNamespace(), group: $this->getSdkGroup(), - name: self::getName(), + name: 'deleteIndex', // getName needs to be different from parent action to avoid conflict in path name description: '/docs/references/databases/delete-index.md', auth: [AuthType::KEY], responses: [ diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Get.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Get.php index 0cc537d960..a765bfb975 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Get.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/Get.php @@ -18,6 +18,11 @@ class Get extends IndexGet { use HTTP; + public static function getName(): string + { + return 'getColumnIndex'; + } + protected function getResponseModel(): string { return UtopiaResponse::MODEL_COLUMN_INDEX; @@ -37,7 +42,7 @@ class Get extends IndexGet ->label('sdk', new Method( namespace: $this->getSdkNamespace(), group: $this->getSdkGroup(), - name: self::getName(), + name: 'getIndex', // getName needs to be different from parent action to avoid conflict in path name description: '/docs/references/databases/get-index.md', auth: [AuthType::KEY], responses: [ diff --git a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/XList.php b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/XList.php index 5a245cf533..afce04fcf9 100644 --- a/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/XList.php +++ b/src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Indexes/XList.php @@ -18,6 +18,11 @@ class XList extends IndexXList { use HTTP; + public static function getName(): string + { + return 'listColumnIndexes'; + } + protected function getResponseModel(): string { return UtopiaResponse::MODEL_COLUMN_INDEX_LIST; @@ -37,7 +42,7 @@ class XList extends IndexXList ->label('sdk', new Method( namespace: $this->getSdkNamespace(), group: $this->getSdkGroup(), - name: self::getName(), + name: 'listIndexes', // getName needs to be different from parent action to avoid conflict in path name description: '/docs/references/databases/list-indexes.md', auth: [AuthType::KEY], responses: [ diff --git a/src/Appwrite/Platform/Modules/Databases/Services/Registry/Tables.php b/src/Appwrite/Platform/Modules/Databases/Services/Registry/Tables.php index 5c544a9d1f..d881303c1e 100644 --- a/src/Appwrite/Platform/Modules/Databases/Services/Registry/Tables.php +++ b/src/Appwrite/Platform/Modules/Databases/Services/Registry/Tables.php @@ -59,7 +59,7 @@ class Tables extends Base { $this->registerTableActions($service); $this->registerColumnActions($service); - $this->registerColumnIndexActions($service); + $this->registerIndexActions($service); $this->registerRowActions($service); } @@ -122,7 +122,7 @@ class Tables extends Base $service->addAction(UpdateURL::getName(), new UpdateURL()); } - private function registerColumnIndexActions(Service $service): void + private function registerIndexActions(Service $service): void { $service->addAction(CreateColumnIndex::getName(), new CreateColumnIndex()); $service->addAction(GetColumnIndex::getName(), new GetColumnIndex());