From 773784edf39cf7b7e1a6f643929c502e4bddaecf Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 18 Jul 2025 12:50:06 +1200 Subject: [PATCH 1/4] Add inc/dec --- README.md | 2 +- docs/databases.md | 74 +++++++- docs/examples/databases/create-document.md | 1 + .../databases/decrement-document-attribute.md | 20 +++ .../databases/increment-document-attribute.md | 20 +++ docs/examples/databases/upsert-document.md | 19 ++ docs/examples/databases/upsert-documents.md | 2 +- docs/tokens.md | 2 +- docs/users.md | 2 +- src/Appwrite/Client.php | 4 +- src/Appwrite/Enums/BuildRuntime.php | 16 ++ src/Appwrite/Enums/ImageFormat.php | 8 + src/Appwrite/Enums/Runtime.php | 16 ++ src/Appwrite/Services/Databases.php | 163 +++++++++++++++++- src/Appwrite/Services/Tokens.php | 2 +- tests/Appwrite/Services/DatabasesTest.php | 84 ++++++++- 16 files changed, 414 insertions(+), 21 deletions(-) create mode 100644 docs/examples/databases/decrement-document-attribute.md create mode 100644 docs/examples/databases/increment-document-attribute.md create mode 100644 docs/examples/databases/upsert-document.md diff --git a/README.md b/README.md index 1c5d4cd..382a055 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) diff --git a/docs/databases.md b/docs/databases.md index 5ca5264..067ff57 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -623,7 +623,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** ### Parameters @@ -638,8 +640,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. - ** +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** ### Parameters @@ -647,14 +650,16 @@ PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | -| documents | array | Array of document data as JSON objects. May contain partial documents. | [] | +| documents | array | Array of document data as JSON objects. May contain partial documents. | | ```http request PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. ** +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. ** ### Parameters @@ -670,7 +675,9 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents ``` -** Bulk delete documents using queries, if no queries are passed then all documents are deleted. ** +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Bulk delete documents using queries, if no queries are passed then all documents are deleted. ** ### Parameters @@ -697,6 +704,25 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | +```http request +PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} +``` + +** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. + +Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. | | +| documentId | string | **Required** Document ID. | | +| data | object | Document data as JSON object. Include all required attributes of the document to be created or updated. | {} | +| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | + + ```http request PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId} ``` @@ -729,6 +755,42 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti | documentId | string | **Required** Document ID. | | +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement +``` + +** Decrement a specific attribute of a document by a given value. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. | | +| documentId | string | **Required** Document ID. | | +| attribute | string | **Required** Attribute key. | | +| value | number | Value to decrement the attribute by. The value must be a number. | 1 | +| min | number | Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment +``` + +** Increment a specific attribute of a document by a given value. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| collectionId | string | **Required** Collection ID. | | +| documentId | string | **Required** Document ID. | | +| attribute | string | **Required** Attribute key. | | +| value | number | Value to increment the attribute by. The value must be a number. | 1 | +| max | number | Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. | | + + ```http request GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes ``` diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 8726b37..bfc6a42 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -5,6 +5,7 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setAdmin('') // ->setSession('') // The user session to authenticate with ->setKey('') // Your secret API key ->setJWT(''); // Your secret JSON Web Token diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md new file mode 100644 index 0000000..40e14af --- /dev/null +++ b/docs/examples/databases/decrement-document-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->decrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: null, // optional + min: null // optional +); \ No newline at end of file diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md new file mode 100644 index 0000000..fb61d87 --- /dev/null +++ b/docs/examples/databases/increment-document-attribute.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->incrementDocumentAttribute( + databaseId: '', + collectionId: '', + documentId: '', + attribute: '', + value: null, // optional + max: null // optional +); \ No newline at end of file diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md new file mode 100644 index 0000000..6cff829 --- /dev/null +++ b/docs/examples/databases/upsert-document.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$databases = new Databases($client); + +$result = $databases->upsertDocument( + databaseId: '', + collectionId: '', + documentId: '', + data: [], + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 7b9459e..d9f9efd 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -13,5 +13,5 @@ $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', collectionId: '', - documents: [] // optional + documents: [] ); \ No newline at end of file diff --git a/docs/tokens.md b/docs/tokens.md index ba4c5df..ca3d831 100644 --- a/docs/tokens.md +++ b/docs/tokens.md @@ -20,7 +20,7 @@ GET https://cloud.appwrite.io/v1/tokens/buckets/{bucketId}/files/{fileId} POST https://cloud.appwrite.io/v1/tokens/buckets/{bucketId}/files/{fileId} ``` -** Create a new token. A token is linked to a file. Token can be passed as a header or request get parameter. ** +** Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. ** ### Parameters diff --git a/docs/users.md b/docs/users.md index 89c3cba..a31ac8c 100644 --- a/docs/users.md +++ b/docs/users.md @@ -509,7 +509,7 @@ GET https://cloud.appwrite.io/v1/users/{userId}/targets | Field Name | Type | Description | Default | | --- | --- | --- | --- | | userId | string | **Required** User ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, email, phone, status, passwordUpdate, registration, emailVerification, phoneVerification, labels | [] | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, providerId, identifier, providerType | [] | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 27f8cca..4288210 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/15.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/15.1.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '15.0.0', + 'x-sdk-version'=> '15.1.0', ]; /** diff --git a/src/Appwrite/Enums/BuildRuntime.php b/src/Appwrite/Enums/BuildRuntime.php index 0c0936a..4fea891 100644 --- a/src/Appwrite/Enums/BuildRuntime.php +++ b/src/Appwrite/Enums/BuildRuntime.php @@ -43,6 +43,7 @@ class BuildRuntime implements JsonSerializable private static BuildRuntime $DART31; private static BuildRuntime $DART33; private static BuildRuntime $DART35; + private static BuildRuntime $DART38; private static BuildRuntime $DOTNET60; private static BuildRuntime $DOTNET70; private static BuildRuntime $DOTNET80; @@ -69,6 +70,7 @@ class BuildRuntime implements JsonSerializable private static BuildRuntime $FLUTTER324; private static BuildRuntime $FLUTTER327; private static BuildRuntime $FLUTTER329; + private static BuildRuntime $FLUTTER332; private string $value; @@ -346,6 +348,13 @@ public static function DART35(): BuildRuntime } return self::$DART35; } + public static function DART38(): BuildRuntime + { + if (!isset(self::$DART38)) { + self::$DART38 = new BuildRuntime('dart-3.8'); + } + return self::$DART38; + } public static function DOTNET60(): BuildRuntime { if (!isset(self::$DOTNET60)) { @@ -528,4 +537,11 @@ public static function FLUTTER329(): BuildRuntime } return self::$FLUTTER329; } + public static function FLUTTER332(): BuildRuntime + { + if (!isset(self::$FLUTTER332)) { + self::$FLUTTER332 = new BuildRuntime('flutter-3.32'); + } + return self::$FLUTTER332; + } } \ No newline at end of file diff --git a/src/Appwrite/Enums/ImageFormat.php b/src/Appwrite/Enums/ImageFormat.php index 0ea7a98..8cb2ce6 100644 --- a/src/Appwrite/Enums/ImageFormat.php +++ b/src/Appwrite/Enums/ImageFormat.php @@ -12,6 +12,7 @@ class ImageFormat implements JsonSerializable private static ImageFormat $WEBP; private static ImageFormat $HEIC; private static ImageFormat $AVIF; + private static ImageFormat $GIF; private string $value; @@ -72,4 +73,11 @@ public static function AVIF(): ImageFormat } return self::$AVIF; } + public static function GIF(): ImageFormat + { + if (!isset(self::$GIF)) { + self::$GIF = new ImageFormat('gif'); + } + return self::$GIF; + } } \ No newline at end of file diff --git a/src/Appwrite/Enums/Runtime.php b/src/Appwrite/Enums/Runtime.php index f29a4d2..a210be9 100644 --- a/src/Appwrite/Enums/Runtime.php +++ b/src/Appwrite/Enums/Runtime.php @@ -43,6 +43,7 @@ class Runtime implements JsonSerializable private static Runtime $DART31; private static Runtime $DART33; private static Runtime $DART35; + private static Runtime $DART38; private static Runtime $DOTNET60; private static Runtime $DOTNET70; private static Runtime $DOTNET80; @@ -69,6 +70,7 @@ class Runtime implements JsonSerializable private static Runtime $FLUTTER324; private static Runtime $FLUTTER327; private static Runtime $FLUTTER329; + private static Runtime $FLUTTER332; private string $value; @@ -346,6 +348,13 @@ public static function DART35(): Runtime } return self::$DART35; } + public static function DART38(): Runtime + { + if (!isset(self::$DART38)) { + self::$DART38 = new Runtime('dart-3.8'); + } + return self::$DART38; + } public static function DOTNET60(): Runtime { if (!isset(self::$DOTNET60)) { @@ -528,4 +537,11 @@ public static function FLUTTER329(): Runtime } return self::$FLUTTER329; } + public static function FLUTTER332(): Runtime + { + if (!isset(self::$FLUTTER332)) { + self::$FLUTTER332 = new Runtime('flutter-3.32'); + } + return self::$FLUTTER332; + } } \ No newline at end of file diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 66b293c..feca082 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -1535,6 +1535,10 @@ public function createDocument(string $databaseId, string $collectionId, string } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Create new Documents. Before using this route, you should create a new * collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) @@ -1571,19 +1575,22 @@ public function createDocuments(string $databaseId, string $collectionId, array } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Create or update Documents. Before using this route, you should create a * new collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) * API or directly from your database console. - * * * @param string $databaseId * @param string $collectionId - * @param ?array $documents + * @param array $documents * @throws AppwriteException * @return array */ - public function upsertDocuments(string $databaseId, string $collectionId, ?array $documents = null): array + public function upsertDocuments(string $databaseId, string $collectionId, array $documents): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1594,10 +1601,7 @@ public function upsertDocuments(string $databaseId, string $collectionId, ?array $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['collectionId'] = $collectionId; - - if (!is_null($documents)) { - $apiParams['documents'] = $documents; - } + $apiParams['documents'] = $documents; $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1611,6 +1615,10 @@ public function upsertDocuments(string $databaseId, string $collectionId, ?array } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Update all documents that match your queries, if no queries are submitted * then all documents are updated. You can pass only specific fields to be * updated. @@ -1654,6 +1662,10 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array } /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * * Bulk delete documents using queries, if no queries are passed then all * documents are deleted. * @@ -1728,6 +1740,53 @@ public function getDocument(string $databaseId, string $collectionId, string $do ); } + /** + * **WARNING: Experimental Feature** - This endpoint is experimental and not + * yet officially supported. It may be subject to breaking changes or removal + * in future versions. + * + * Create or update a Document. Before using this route, you should create a + * new collection resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $collectionId + * @param string $documentId + * @param array $data + * @param ?array $permissions + * @throws AppwriteException + * @return array + */ + public function upsertDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{documentId}'], + [$databaseId, $collectionId, $documentId], + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['documentId'] = $documentId; + $apiParams['data'] = $data; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * Update a document by its unique ID. Using the patch method you can pass * only specific fields that will get updated. @@ -1805,6 +1864,96 @@ public function deleteDocument(string $databaseId, string $collectionId, string ); } + /** + * Decrement a specific attribute of a document by a given value. + * + * @param string $databaseId + * @param string $collectionId + * @param string $documentId + * @param string $attribute + * @param ?float $value + * @param ?float $min + * @throws AppwriteException + * @return array + */ + public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], + [$databaseId, $collectionId, $documentId, $attribute], + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['documentId'] = $documentId; + $apiParams['attribute'] = $attribute; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Increment a specific attribute of a document by a given value. + * + * @param string $databaseId + * @param string $collectionId + * @param string $documentId + * @param string $attribute + * @param ?float $value + * @param ?float $max + * @throws AppwriteException + * @return array + */ + public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{documentId}', '{attribute}'], + [$databaseId, $collectionId, $documentId, $attribute], + '/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['documentId'] = $documentId; + $apiParams['attribute'] = $attribute; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + /** * List indexes in the collection. * diff --git a/src/Appwrite/Services/Tokens.php b/src/Appwrite/Services/Tokens.php index 4811f4a..572321a 100644 --- a/src/Appwrite/Services/Tokens.php +++ b/src/Appwrite/Services/Tokens.php @@ -52,7 +52,7 @@ public function list(string $bucketId, string $fileId, ?array $queries = null): /** * Create a new token. A token is linked to a file. Token can be passed as a - * header or request get parameter. + * request URL search parameter. * * @param string $bucketId * @param string $fileId diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index d8ecfd5..e870542 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -867,6 +867,7 @@ public function testMethodCreateDocument(): void { $data = array( "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, "\$collectionId" => "5e5ea5c15117e", "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -921,7 +922,8 @@ public function testMethodUpsertDocuments(): void { $response = $this->databases->upsertDocuments( "", - "" + "", + array() ); $this->assertSame($data, $response); @@ -969,6 +971,7 @@ public function testMethodGetDocument(): void { $data = array( "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, "\$collectionId" => "5e5ea5c15117e", "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -989,10 +992,37 @@ public function testMethodGetDocument(): void { $this->assertSame($data, $response); } + public function testMethodUpsertDocument(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->upsertDocument( + "", + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + public function testMethodUpdateDocument(): void { $data = array( "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, "\$collectionId" => "5e5ea5c15117e", "\$databaseId" => "5e5ea5c15117e", "\$createdAt" => "2020-10-15T06:38:00.000+00:00", @@ -1031,6 +1061,58 @@ public function testMethodDeleteDocument(): void { $this->assertSame($data, $response); } + public function testMethodDecrementDocumentAttribute(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->decrementDocumentAttribute( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodIncrementDocumentAttribute(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$collectionId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->incrementDocumentAttribute( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + public function testMethodListIndexes(): void { $data = array( From 6bd335d34310e54c8e5a4fdd5cc5cc4d0c17f9e1 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 22 Jul 2025 16:16:32 +0000 Subject: [PATCH 2/4] chore: regenerate --- README.md | 4 +- docs/databases.md | 106 +- docs/examples/databases/create-document.md | 1 - docs/examples/databases/create-documents.md | 1 + docs/examples/databases/upsert-document.md | 9 +- docs/examples/databases/upsert-documents.md | 5 +- docs/examples/tables/create-boolean-column.md | 20 + .../examples/tables/create-datetime-column.md | 20 + docs/examples/tables/create-email-column.md | 20 + docs/examples/tables/create-enum-column.md | 21 + docs/examples/tables/create-float-column.md | 22 + docs/examples/tables/create-index.md | 22 + docs/examples/tables/create-integer-column.md | 22 + docs/examples/tables/create-ip-column.md | 20 + .../tables/create-relationship-column.md | 23 + docs/examples/tables/create-row.md | 20 + docs/examples/tables/create-rows.md | 17 + docs/examples/tables/create-string-column.md | 22 + docs/examples/tables/create-url-column.md | 20 + docs/examples/tables/create.md | 20 + docs/examples/tables/decrement-row-column.md | 20 + docs/examples/tables/delete-column.md | 17 + docs/examples/tables/delete-index.md | 17 + docs/examples/tables/delete-row.md | 17 + docs/examples/tables/delete-rows.md | 17 + docs/examples/tables/delete.md | 16 + docs/examples/tables/get-column.md | 17 + docs/examples/tables/get-index.md | 17 + docs/examples/tables/get-row.md | 18 + docs/examples/tables/get.md | 16 + docs/examples/tables/increment-row-column.md | 20 + docs/examples/tables/list-columns.md | 17 + docs/examples/tables/list-indexes.md | 17 + docs/examples/tables/list-rows.md | 17 + docs/examples/tables/list.md | 17 + docs/examples/tables/update-boolean-column.md | 20 + .../examples/tables/update-datetime-column.md | 20 + docs/examples/tables/update-email-column.md | 20 + docs/examples/tables/update-enum-column.md | 21 + docs/examples/tables/update-float-column.md | 22 + docs/examples/tables/update-integer-column.md | 22 + docs/examples/tables/update-ip-column.md | 20 + .../tables/update-relationship-column.md | 19 + docs/examples/tables/update-row.md | 19 + docs/examples/tables/update-rows.md | 18 + docs/examples/tables/update-string-column.md | 21 + docs/examples/tables/update-url-column.md | 20 + docs/examples/tables/update.md | 20 + docs/examples/tables/upsert-row.md | 18 + docs/examples/tables/upsert-rows.md | 16 + docs/tables.md | 773 +++++++ src/Appwrite/Client.php | 6 +- src/Appwrite/Services/Account.php | 4 + src/Appwrite/Services/Databases.php | 150 +- src/Appwrite/Services/Tables.php | 1906 +++++++++++++++++ tests/Appwrite/Services/DatabasesTest.php | 6 +- tests/Appwrite/Services/TablesTest.php | 1107 ++++++++++ 57 files changed, 4838 insertions(+), 85 deletions(-) create mode 100644 docs/examples/tables/create-boolean-column.md create mode 100644 docs/examples/tables/create-datetime-column.md create mode 100644 docs/examples/tables/create-email-column.md create mode 100644 docs/examples/tables/create-enum-column.md create mode 100644 docs/examples/tables/create-float-column.md create mode 100644 docs/examples/tables/create-index.md create mode 100644 docs/examples/tables/create-integer-column.md create mode 100644 docs/examples/tables/create-ip-column.md create mode 100644 docs/examples/tables/create-relationship-column.md create mode 100644 docs/examples/tables/create-row.md create mode 100644 docs/examples/tables/create-rows.md create mode 100644 docs/examples/tables/create-string-column.md create mode 100644 docs/examples/tables/create-url-column.md create mode 100644 docs/examples/tables/create.md create mode 100644 docs/examples/tables/decrement-row-column.md create mode 100644 docs/examples/tables/delete-column.md create mode 100644 docs/examples/tables/delete-index.md create mode 100644 docs/examples/tables/delete-row.md create mode 100644 docs/examples/tables/delete-rows.md create mode 100644 docs/examples/tables/delete.md create mode 100644 docs/examples/tables/get-column.md create mode 100644 docs/examples/tables/get-index.md create mode 100644 docs/examples/tables/get-row.md create mode 100644 docs/examples/tables/get.md create mode 100644 docs/examples/tables/increment-row-column.md create mode 100644 docs/examples/tables/list-columns.md create mode 100644 docs/examples/tables/list-indexes.md create mode 100644 docs/examples/tables/list-rows.md create mode 100644 docs/examples/tables/list.md create mode 100644 docs/examples/tables/update-boolean-column.md create mode 100644 docs/examples/tables/update-datetime-column.md create mode 100644 docs/examples/tables/update-email-column.md create mode 100644 docs/examples/tables/update-enum-column.md create mode 100644 docs/examples/tables/update-float-column.md create mode 100644 docs/examples/tables/update-integer-column.md create mode 100644 docs/examples/tables/update-ip-column.md create mode 100644 docs/examples/tables/update-relationship-column.md create mode 100644 docs/examples/tables/update-row.md create mode 100644 docs/examples/tables/update-rows.md create mode 100644 docs/examples/tables/update-string-column.md create mode 100644 docs/examples/tables/update-url-column.md create mode 100644 docs/examples/tables/update.md create mode 100644 docs/examples/tables/upsert-row.md create mode 100644 docs/examples/tables/upsert-rows.md create mode 100644 docs/tables.md create mode 100644 src/Appwrite/Services/Tables.php create mode 100644 tests/Appwrite/Services/TablesTest.php diff --git a/README.md b/README.md index 382a055..3fc6168 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** +**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/docs/databases.md b/docs/databases.md index 067ff57..a4a7104 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -162,7 +162,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error | [] | @@ -178,7 +178,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | boolean | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -196,7 +196,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | boolean | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -214,7 +214,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. | | @@ -232,7 +232,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -251,7 +251,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -270,18 +270,18 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/enum ``` -** Create an enumeration attribute. The `elements` param acts as a white-list of accepted values for this attribute. +** Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. ** ### Parameters @@ -289,9 +289,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | -| elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long. | | +| elements | array | Array of enum values. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -309,12 +309,12 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | -| elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long. | | +| elements | array | Updated list of enum values. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request @@ -329,12 +329,12 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| min | number | Minimum value to enforce on new documents | | -| max | number | Maximum value to enforce on new documents | | -| default | number | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| min | number | Minimum value. | | +| max | number | Maximum value. | | +| default | number | Default value. Cannot be set when required. | | | array | boolean | Is attribute an array? | | @@ -350,13 +350,13 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| min | number | Minimum value to enforce on new documents | | -| max | number | Maximum value to enforce on new documents | | -| default | number | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| min | number | Minimum value. | | +| max | number | Maximum value. | | +| default | number | Default value. Cannot be set when required. | | +| newKey | string | New Attribute Key. | | ```http request @@ -371,12 +371,12 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| min | integer | Minimum value to enforce on new documents | | -| max | integer | Maximum value to enforce on new documents | | -| default | integer | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| min | integer | Minimum value | | +| max | integer | Maximum value | | +| default | integer | Default value. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -392,13 +392,13 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| min | integer | Minimum value to enforce on new documents | | -| max | integer | Maximum value to enforce on new documents | | -| default | integer | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| min | integer | Minimum value | | +| max | integer | Maximum value | | +| default | integer | Default value. Cannot be set when attribute is required. | | +| newKey | string | New Attribute Key. | | ```http request @@ -413,10 +413,10 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| default | string | Default value. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -432,11 +432,11 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| default | string | Default value. Cannot be set when attribute is required. | | +| newKey | string | New Attribute Key. | | ```http request @@ -451,8 +451,8 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | -| relatedCollectionId | string | Related Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | +| relatedCollectionId | string | Related Collection ID. | | | type | string | Relation type | | | twoWay | boolean | Is Two Way? | | | key | string | Attribute Key. | | @@ -472,7 +472,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | size | integer | Attribute size for text attributes, in number of characters. | | | required | boolean | Is attribute required? | | @@ -493,12 +493,12 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | | size | integer | Maximum size of the string attribute. | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request @@ -513,7 +513,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -532,11 +532,11 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request @@ -550,7 +550,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | @@ -565,7 +565,7 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | @@ -581,10 +581,10 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. | | | key | string | **Required** Attribute Key. | | | onDelete | string | Constraints option | | -| newKey | string | New attribute key. | | +| newKey | string | New Attribute Key. | | ```http request @@ -642,7 +642,8 @@ PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI ** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions. -Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. ** +Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. + ** ### Parameters @@ -650,7 +651,6 @@ Create or update Documents. Before using this route, you should create a new col | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | -| documents | array | Array of document data as JSON objects. May contain partial documents. | | ```http request @@ -719,8 +719,6 @@ Create or update a Document. Before using this route, you should create a new co | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | | documentId | string | **Required** Document ID. | | -| data | object | Document data as JSON object. Include all required attributes of the document to be created or updated. | {} | -| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | ```http request @@ -769,7 +767,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | collectionId | string | **Required** Collection ID. | | | documentId | string | **Required** Document ID. | | | attribute | string | **Required** Attribute key. | | -| value | number | Value to decrement the attribute by. The value must be a number. | 1 | +| value | number | Value to increment the attribute by. The value must be a number. | 1 | | min | number | Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. | | diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index bfc6a42..8726b37 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -5,7 +5,6 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setAdmin('') // ->setSession('') // The user session to authenticate with ->setKey('') // Your secret API key ->setJWT(''); // Your secret JSON Web Token diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 96008e2..9429b57 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -5,6 +5,7 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setAdmin('') // ->setKey(''); // Your secret API key $databases = new Databases($client); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 6cff829..2f8464c 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -5,15 +5,14 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with + ->setSession('') // The user session to authenticate with + ->setKey('') // Your secret API key + ->setJWT(''); // Your secret JSON Web Token $databases = new Databases($client); $result = $databases->upsertDocument( databaseId: '', collectionId: '', - documentId: '', - data: [], - permissions: ["read("any")"] // optional + documentId: '' ); \ No newline at end of file diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index d9f9efd..11898dc 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -5,13 +5,12 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID + ->setAdmin('') // ->setKey(''); // Your secret API key $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', - collectionId: '', - documents: [] + collectionId: '' ); \ No newline at end of file diff --git a/docs/examples/tables/create-boolean-column.md b/docs/examples/tables/create-boolean-column.md new file mode 100644 index 0000000..2833975 --- /dev/null +++ b/docs/examples/tables/create-boolean-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createBooleanColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: false, // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-datetime-column.md b/docs/examples/tables/create-datetime-column.md new file mode 100644 index 0000000..d7f18f2 --- /dev/null +++ b/docs/examples/tables/create-datetime-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createDatetimeColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-email-column.md b/docs/examples/tables/create-email-column.md new file mode 100644 index 0000000..15ec2cf --- /dev/null +++ b/docs/examples/tables/create-email-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createEmailColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: 'email@example.com', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-enum-column.md b/docs/examples/tables/create-enum-column.md new file mode 100644 index 0000000..aa2b613 --- /dev/null +++ b/docs/examples/tables/create-enum-column.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createEnumColumn( + databaseId: '', + tableId: '', + key: '', + elements: [], + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-float-column.md b/docs/examples/tables/create-float-column.md new file mode 100644 index 0000000..1f620dc --- /dev/null +++ b/docs/examples/tables/create-float-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createFloatColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-index.md b/docs/examples/tables/create-index.md new file mode 100644 index 0000000..9844e04 --- /dev/null +++ b/docs/examples/tables/create-index.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createIndex( + databaseId: '', + tableId: '', + key: '', + type: IndexType::KEY(), + columns: [], + orders: [], // optional + lengths: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-integer-column.md b/docs/examples/tables/create-integer-column.md new file mode 100644 index 0000000..185f12c --- /dev/null +++ b/docs/examples/tables/create-integer-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createIntegerColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + min: null, // optional + max: null, // optional + default: null, // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-ip-column.md b/docs/examples/tables/create-ip-column.md new file mode 100644 index 0000000..1f74e4d --- /dev/null +++ b/docs/examples/tables/create-ip-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createIpColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-relationship-column.md b/docs/examples/tables/create-relationship-column.md new file mode 100644 index 0000000..c86b4c5 --- /dev/null +++ b/docs/examples/tables/create-relationship-column.md @@ -0,0 +1,23 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createRelationshipColumn( + databaseId: '', + tableId: '', + relatedTableId: '', + type: RelationshipType::ONETOONE(), + twoWay: false, // optional + key: '', // optional + twoWayKey: '', // optional + onDelete: RelationMutate::CASCADE() // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md new file mode 100644 index 0000000..6b64a7e --- /dev/null +++ b/docs/examples/tables/create-row.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setSession('') // The user session to authenticate with + ->setKey('') // Your secret API key + ->setJWT(''); // Your secret JSON Web Token + +$tables = new Tables($client); + +$result = $tables->createRow( + databaseId: '', + tableId: '', + rowId: '', + data: [], + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md new file mode 100644 index 0000000..a1bf72a --- /dev/null +++ b/docs/examples/tables/create-rows.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setAdmin('') // + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createRows( + databaseId: '', + tableId: '', + rows: [] +); \ No newline at end of file diff --git a/docs/examples/tables/create-string-column.md b/docs/examples/tables/create-string-column.md new file mode 100644 index 0000000..085aff2 --- /dev/null +++ b/docs/examples/tables/create-string-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createStringColumn( + databaseId: '', + tableId: '', + key: '', + size: 1, + required: false, + default: '', // optional + array: false, // optional + encrypt: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create-url-column.md b/docs/examples/tables/create-url-column.md new file mode 100644 index 0000000..d0bdb55 --- /dev/null +++ b/docs/examples/tables/create-url-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->createUrlColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: 'https://example.com', // optional + array: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/create.md b/docs/examples/tables/create.md new file mode 100644 index 0000000..773d7a2 --- /dev/null +++ b/docs/examples/tables/create.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->create( + databaseId: '', + tableId: '', + name: '', + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/decrement-row-column.md b/docs/examples/tables/decrement-row-column.md new file mode 100644 index 0000000..b0c44b6 --- /dev/null +++ b/docs/examples/tables/decrement-row-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->decrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + value: null, // optional + min: null // optional +); \ No newline at end of file diff --git a/docs/examples/tables/delete-column.md b/docs/examples/tables/delete-column.md new file mode 100644 index 0000000..9bd6738 --- /dev/null +++ b/docs/examples/tables/delete-column.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->deleteColumn( + databaseId: '', + tableId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/tables/delete-index.md b/docs/examples/tables/delete-index.md new file mode 100644 index 0000000..bbd7484 --- /dev/null +++ b/docs/examples/tables/delete-index.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->deleteIndex( + databaseId: '', + tableId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md new file mode 100644 index 0000000..0c4ab6e --- /dev/null +++ b/docs/examples/tables/delete-row.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tables = new Tables($client); + +$result = $tables->deleteRow( + databaseId: '', + tableId: '', + rowId: '' +); \ No newline at end of file diff --git a/docs/examples/tables/delete-rows.md b/docs/examples/tables/delete-rows.md new file mode 100644 index 0000000..b0c984c --- /dev/null +++ b/docs/examples/tables/delete-rows.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->deleteRows( + databaseId: '', + tableId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/delete.md b/docs/examples/tables/delete.md new file mode 100644 index 0000000..f145eed --- /dev/null +++ b/docs/examples/tables/delete.md @@ -0,0 +1,16 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->delete( + databaseId: '', + tableId: '' +); \ No newline at end of file diff --git a/docs/examples/tables/get-column.md b/docs/examples/tables/get-column.md new file mode 100644 index 0000000..b8b6765 --- /dev/null +++ b/docs/examples/tables/get-column.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->getColumn( + databaseId: '', + tableId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/tables/get-index.md b/docs/examples/tables/get-index.md new file mode 100644 index 0000000..5d1139d --- /dev/null +++ b/docs/examples/tables/get-index.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->getIndex( + databaseId: '', + tableId: '', + key: '' +); \ No newline at end of file diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md new file mode 100644 index 0000000..ccde387 --- /dev/null +++ b/docs/examples/tables/get-row.md @@ -0,0 +1,18 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tables = new Tables($client); + +$result = $tables->getRow( + databaseId: '', + tableId: '', + rowId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/get.md b/docs/examples/tables/get.md new file mode 100644 index 0000000..d07ef73 --- /dev/null +++ b/docs/examples/tables/get.md @@ -0,0 +1,16 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->get( + databaseId: '', + tableId: '' +); \ No newline at end of file diff --git a/docs/examples/tables/increment-row-column.md b/docs/examples/tables/increment-row-column.md new file mode 100644 index 0000000..aa5a3c0 --- /dev/null +++ b/docs/examples/tables/increment-row-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->incrementRowColumn( + databaseId: '', + tableId: '', + rowId: '', + column: '', + value: null, // optional + max: null // optional +); \ No newline at end of file diff --git a/docs/examples/tables/list-columns.md b/docs/examples/tables/list-columns.md new file mode 100644 index 0000000..0338567 --- /dev/null +++ b/docs/examples/tables/list-columns.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->listColumns( + databaseId: '', + tableId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/list-indexes.md b/docs/examples/tables/list-indexes.md new file mode 100644 index 0000000..df1f8c6 --- /dev/null +++ b/docs/examples/tables/list-indexes.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->listIndexes( + databaseId: '', + tableId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md new file mode 100644 index 0000000..2041d72 --- /dev/null +++ b/docs/examples/tables/list-rows.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tables = new Tables($client); + +$result = $tables->listRows( + databaseId: '', + tableId: '', + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/list.md b/docs/examples/tables/list.md new file mode 100644 index 0000000..37df0a4 --- /dev/null +++ b/docs/examples/tables/list.md @@ -0,0 +1,17 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->list( + databaseId: '', + queries: [], // optional + search: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-boolean-column.md b/docs/examples/tables/update-boolean-column.md new file mode 100644 index 0000000..8ad8050 --- /dev/null +++ b/docs/examples/tables/update-boolean-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateBooleanColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: false, + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-datetime-column.md b/docs/examples/tables/update-datetime-column.md new file mode 100644 index 0000000..5185357 --- /dev/null +++ b/docs/examples/tables/update-datetime-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateDatetimeColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-email-column.md b/docs/examples/tables/update-email-column.md new file mode 100644 index 0000000..7acbb81 --- /dev/null +++ b/docs/examples/tables/update-email-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateEmailColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: 'email@example.com', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-enum-column.md b/docs/examples/tables/update-enum-column.md new file mode 100644 index 0000000..478905a --- /dev/null +++ b/docs/examples/tables/update-enum-column.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateEnumColumn( + databaseId: '', + tableId: '', + key: '', + elements: [], + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-float-column.md b/docs/examples/tables/update-float-column.md new file mode 100644 index 0000000..1d9c5fd --- /dev/null +++ b/docs/examples/tables/update-float-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateFloatColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-integer-column.md b/docs/examples/tables/update-integer-column.md new file mode 100644 index 0000000..f6998db --- /dev/null +++ b/docs/examples/tables/update-integer-column.md @@ -0,0 +1,22 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateIntegerColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: null, + min: null, // optional + max: null, // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-ip-column.md b/docs/examples/tables/update-ip-column.md new file mode 100644 index 0000000..e7906fb --- /dev/null +++ b/docs/examples/tables/update-ip-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateIpColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-relationship-column.md b/docs/examples/tables/update-relationship-column.md new file mode 100644 index 0000000..d6505c7 --- /dev/null +++ b/docs/examples/tables/update-relationship-column.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateRelationshipColumn( + databaseId: '', + tableId: '', + key: '', + onDelete: RelationMutate::CASCADE(), // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md new file mode 100644 index 0000000..921c43d --- /dev/null +++ b/docs/examples/tables/update-row.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with + +$tables = new Tables($client); + +$result = $tables->updateRow( + databaseId: '', + tableId: '', + rowId: '', + data: [], // optional + permissions: ["read("any")"] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-rows.md b/docs/examples/tables/update-rows.md new file mode 100644 index 0000000..f61fa2b --- /dev/null +++ b/docs/examples/tables/update-rows.md @@ -0,0 +1,18 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateRows( + databaseId: '', + tableId: '', + data: [], // optional + queries: [] // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-string-column.md b/docs/examples/tables/update-string-column.md new file mode 100644 index 0000000..8856ec1 --- /dev/null +++ b/docs/examples/tables/update-string-column.md @@ -0,0 +1,21 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateStringColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', + size: 1, // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update-url-column.md b/docs/examples/tables/update-url-column.md new file mode 100644 index 0000000..faa46d1 --- /dev/null +++ b/docs/examples/tables/update-url-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->updateUrlColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: 'https://example.com', + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tables/update.md b/docs/examples/tables/update.md new file mode 100644 index 0000000..39f076b --- /dev/null +++ b/docs/examples/tables/update.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->update( + databaseId: '', + tableId: '', + name: '', + permissions: ["read("any")"], // optional + rowSecurity: false, // optional + enabled: false // optional +); \ No newline at end of file diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md new file mode 100644 index 0000000..2bddd9b --- /dev/null +++ b/docs/examples/tables/upsert-row.md @@ -0,0 +1,18 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setSession('') // The user session to authenticate with + ->setKey('') // Your secret API key + ->setJWT(''); // Your secret JSON Web Token + +$tables = new Tables($client); + +$result = $tables->upsertRow( + databaseId: '', + tableId: '', + rowId: '' +); \ No newline at end of file diff --git a/docs/examples/tables/upsert-rows.md b/docs/examples/tables/upsert-rows.md new file mode 100644 index 0000000..5ed5f02 --- /dev/null +++ b/docs/examples/tables/upsert-rows.md @@ -0,0 +1,16 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setAdmin('') // + ->setKey(''); // Your secret API key + +$tables = new Tables($client); + +$result = $tables->upsertRows( + databaseId: '', + tableId: '' +); \ No newline at end of file diff --git a/docs/tables.md b/docs/tables.md new file mode 100644 index 0000000..4de77e4 --- /dev/null +++ b/docs/tables.md @@ -0,0 +1,773 @@ +# Tables Service + + +```http request +GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables +``` + +** Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, rowSecurity | [] | +| search | string | Search term to filter your list results. Max length: 256 chars. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables +``` + +** Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| name | string | Table name. Max length: 128 chars. | | +| permissions | array | An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | + + +```http request +GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId} +``` + +** Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | + + +```http request +PUT https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId} +``` + +** Update a table by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| name | string | Table name. Max length: 128 chars. | | +| permissions | array | An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). | | +| enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | + + +```http request +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId} +``` + +** Delete a table by its unique ID. Only users with write permissions have access to delete this resource. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | + + +```http request +GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns +``` + +** List attributes in the collection. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error | [] | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/boolean +``` + +** Create a boolean column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | boolean | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/boolean/{key} +``` + +** Update a boolean column. Changing the `default` value will not update already existing rows. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | boolean | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/datetime +``` + +** Create a date time column according to the ISO 8601 standard. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/datetime/{key} +``` + +** Update a date time column. Changing the `default` value will not update already existing rows. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/email +``` + +** Create an email column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/email/{key} +``` + +** Update an email column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/enum +``` + +** Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| elements | array | Array of enum values. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/enum/{key} +``` + +** Update an enum column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| elements | array | Updated list of enum values. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/float +``` + +** Create a float column. Optionally, minimum and maximum values can be provided. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| min | number | Minimum value | | +| max | number | Maximum value | | +| default | number | Default value. Cannot be set when required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/float/{key} +``` + +** Update a float column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| min | number | Minimum value | | +| max | number | Maximum value | | +| default | number | Default value. Cannot be set when required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/integer +``` + +** Create an integer column. Optionally, minimum and maximum values can be provided. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| min | integer | Minimum value | | +| max | integer | Maximum value | | +| default | integer | Default value. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/integer/{key} +``` + +** Update an integer column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| min | integer | Minimum value | | +| max | integer | Maximum value | | +| default | integer | Default value. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/ip +``` + +** Create IP address column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/ip/{key} +``` + +** Update an ip column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/relationship +``` + +** Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| relatedTableId | string | Related Table ID. | | +| type | string | Relation type | | +| twoWay | boolean | Is Two Way? | | +| key | string | Column Key. | | +| twoWayKey | string | Two Way Column Key. | | +| onDelete | string | Constraints option | restrict | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/string +``` + +** Create a string column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| key | string | Column Key. | | +| size | integer | Attribute size for text attributes, in number of characters. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | +| encrypt | boolean | Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/string/{key} +``` + +** Update a string column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| size | integer | Maximum size of the string column. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/url +``` + +** Create a URL column. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| array | boolean | Is column an array? | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/url/{key} +``` + +** Update an url column. Changing the `default` value will not update already existing rows. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/{key} +``` + +** Get column by ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | + + +```http request +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/{key} +``` + +** Deletes a column. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/{key}/relationship +``` + +** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| key | string | **Required** Column Key. | | +| onDelete | string | Constraints option | | +| newKey | string | New Column Key. | | + + +```http request +GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/indexes +``` + +** List indexes in the collection. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error | [] | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/indexes +``` + +** Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. +Attributes can be `key`, `fulltext`, and `unique`. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| key | string | Index Key. | | +| type | string | Index type. | | +| columns | array | Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. | | +| orders | array | Array of index orders. Maximum of 100 orders are allowed. | [] | +| lengths | array | Length of index. Maximum of 100 | [] | + + +```http request +GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/indexes/{key} +``` + +** Get index by ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| key | string | **Required** Index Key. | | + + +```http request +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/indexes/{key} +``` + +** Delete an index. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| key | string | **Required** Index Key. | | + + +```http request +GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows +``` + +** Get a list of all the user's rows in a given table. You can use the query params to filter your results. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows +``` + +** Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. | | +| rowId | string | Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | +| data | object | Row data as JSON object. | {} | +| permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows +``` + +** Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. | | +| rows | array | Array of documents data as JSON objects. | [] | + + +```http request +PUT https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows +``` + +** Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. + ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows +``` + +** Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| data | object | Row data as JSON object. Include only column and value pairs to be updated. | {} | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows +``` + +** Bulk delete rows using queries, if no queries are passed then all rows are deleted. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId} +``` + +** Get a row by its unique ID. This endpoint response returns a JSON object with the row data. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| rowId | string | **Required** Row ID. | | +| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | + + +```http request +PUT https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId} +``` + +** Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rowId | string | **Required** Row ID. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId} +``` + +** Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rowId | string | **Required** Row ID. | | +| data | object | Row data as JSON object. Include only columns and value pairs to be updated. | {} | +| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | + + +```http request +DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId} +``` + +** Delete a row by its unique ID. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | +| rowId | string | **Required** Row ID. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement +``` + +** Decrement a specific column of a row by a given value. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rowId | string | **Required** Row ID. | | +| column | string | **Required** Column key. | | +| value | number | Value to increment the column by. The value must be a number. | 1 | +| min | number | Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment +``` + +** Increment a specific column of a row by a given value. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. | | +| rowId | string | **Required** Row ID. | | +| column | string | **Required** Column key. | | +| value | number | Value to increment the column by. The value must be a number. | 1 | +| max | number | Maximum value for the column. If the current value is greater than this value, an error will be thrown. | | + diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 4288210..5c1c208 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/15.1.0 ()', + 'user-agent' => 'AppwritePHPSDK/16.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '15.1.0', + 'x-sdk-version'=> '16.0.0', ]; /** @@ -49,7 +49,7 @@ class Client */ public function __construct() { - $this->headers['X-Appwrite-Response-Format'] = '1.7.0'; + $this->headers['X-Appwrite-Response-Format'] = '1.8.0'; } diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 13c7d7f..92257b8 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -923,6 +923,8 @@ public function createEmailPasswordSession(string $email, string $password): arr * @param string $secret * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated. */ public function updateMagicURLSession(string $userId, string $secret): array { @@ -956,6 +958,8 @@ public function updateMagicURLSession(string $userId, string $secret): array * @param string $secret * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated. */ public function updatePhoneSession(string $userId, string $secret): array { diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index feca082..7b34e8b 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -195,6 +195,9 @@ public function delete(string $databaseId): string * @param ?string $search * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `list` instead. + * @see Tables::list */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null): array { @@ -239,6 +242,9 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `create` instead. + * @see Tables::create */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): array { @@ -284,6 +290,9 @@ public function createCollection(string $databaseId, string $collectionId, strin * @param string $collectionId * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `get` instead. + * @see Tables::get */ public function getCollection(string $databaseId, string $collectionId): array { @@ -318,6 +327,9 @@ public function getCollection(string $databaseId, string $collectionId): array * @param ?bool $enabled * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `update` instead. + * @see Tables::update */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): array { @@ -363,6 +375,9 @@ public function updateCollection(string $databaseId, string $collectionId, strin * @param string $collectionId * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `delete` instead. + * @see Tables::delete */ public function deleteCollection(string $databaseId, string $collectionId): string { @@ -395,6 +410,9 @@ public function deleteCollection(string $databaseId, string $collectionId): stri * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listColumns` instead. + * @see Tables::listColumns */ public function listAttributes(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -434,6 +452,9 @@ public function listAttributes(string $databaseId, string $collectionId, ?array * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createBooleanColumn` instead. + * @see Tables::createBooleanColumn */ public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): array { @@ -480,6 +501,9 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateBooleanColumn` instead. + * @see Tables::updateBooleanColumn */ public function updateBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): array { @@ -522,6 +546,9 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createDatetimeColumn` instead. + * @see Tables::createDatetimeColumn */ public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -568,6 +595,9 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateDatetimeColumn` instead. + * @see Tables::updateDatetimeColumn */ public function updateDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -611,6 +641,9 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createEmailColumn` instead. + * @see Tables::createEmailColumn */ public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -658,6 +691,9 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateEmailColumn` instead. + * @see Tables::updateEmailColumn */ public function updateEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -690,8 +726,8 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s } /** - * Create an enumeration attribute. The `elements` param acts as a white-list - * of accepted values for this attribute. + * Create an enum attribute. The `elements` param acts as a white-list of + * accepted values for this attribute. * * * @param string $databaseId @@ -703,6 +739,9 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createEnumColumn` instead. + * @see Tables::createEnumColumn */ public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -752,6 +791,9 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateEnumColumn` instead. + * @see Tables::updateEnumColumn */ public function updateEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -799,6 +841,9 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createFloatColumn` instead. + * @see Tables::createFloatColumn */ public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): array { @@ -856,6 +901,9 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateFloatColumn` instead. + * @see Tables::updateFloatColumn */ public function updateFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): array { @@ -910,6 +958,9 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createIntegerColumn` instead. + * @see Tables::createIntegerColumn */ public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): array { @@ -967,6 +1018,9 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateIntegerColumn` instead. + * @see Tables::updateIntegerColumn */ public function updateIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): array { @@ -1018,6 +1072,9 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createIpColumn` instead. + * @see Tables::createIpColumn */ public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -1065,6 +1122,9 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateIpColumn` instead. + * @see Tables::updateIpColumn */ public function updateIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -1111,6 +1171,9 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri * @param ?RelationMutate $onDelete * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createRelationshipColumn` instead. + * @see Tables::createRelationshipColumn */ public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): array { @@ -1167,6 +1230,9 @@ public function createRelationshipAttribute(string $databaseId, string $collecti * @param ?bool $encrypt * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createStringColumn` instead. + * @see Tables::createStringColumn */ public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array { @@ -1220,6 +1286,9 @@ public function createStringAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateStringColumn` instead. + * @see Tables::updateStringColumn */ public function updateStringAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array { @@ -1267,6 +1336,9 @@ public function updateStringAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createUrlColumn` instead. + * @see Tables::createUrlColumn */ public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -1314,6 +1386,9 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateUrlColumn` instead. + * @see Tables::updateUrlColumn */ public function updateUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -1353,6 +1428,9 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str * @param string $key * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getColumn` instead. + * @see Tables::getColumn */ public function getAttribute(string $databaseId, string $collectionId, string $key): array { @@ -1385,6 +1463,9 @@ public function getAttribute(string $databaseId, string $collectionId, string $k * @param string $key * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteColumn` instead. + * @see Tables::deleteColumn */ public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { @@ -1422,6 +1503,9 @@ public function deleteAttribute(string $databaseId, string $collectionId, string * @param ?string $newKey * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateRelationshipColumn` instead. + * @see Tables::updateRelationshipColumn */ public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array { @@ -1464,6 +1548,9 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listRows` instead. + * @see Tables::listRows */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -1504,6 +1591,9 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ * @param ?array $permissions * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createRow` instead. + * @see Tables::createRow */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array { @@ -1549,6 +1639,9 @@ public function createDocument(string $databaseId, string $collectionId, string * @param array $documents * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createRow` instead. + * @see Tables::createRow */ public function createDocuments(string $databaseId, string $collectionId, array $documents): array { @@ -1583,14 +1676,17 @@ public function createDocuments(string $databaseId, string $collectionId, array * new collection resource using either a [server * integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) * API or directly from your database console. + * * * @param string $databaseId * @param string $collectionId - * @param array $documents * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRows` instead. + * @see Tables::upsertRows */ - public function upsertDocuments(string $databaseId, string $collectionId, array $documents): array + public function upsertDocuments(string $databaseId, string $collectionId): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1601,7 +1697,6 @@ public function upsertDocuments(string $databaseId, string $collectionId, array $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['collectionId'] = $collectionId; - $apiParams['documents'] = $documents; $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1629,6 +1724,9 @@ public function upsertDocuments(string $databaseId, string $collectionId, array * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateRows` instead. + * @see Tables::updateRows */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null): array { @@ -1674,6 +1772,9 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteRows` instead. + * @see Tables::deleteRows */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -1712,6 +1813,9 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getRow` instead. + * @see Tables::getRow */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null): array { @@ -1753,12 +1857,13 @@ public function getDocument(string $databaseId, string $collectionId, string $do * @param string $databaseId * @param string $collectionId * @param string $documentId - * @param array $data - * @param ?array $permissions * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRow` instead. + * @see Tables::upsertRow */ - public function upsertDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array + public function upsertDocument(string $databaseId, string $collectionId, string $documentId): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], @@ -1770,11 +1875,6 @@ public function upsertDocument(string $databaseId, string $collectionId, string $apiParams['databaseId'] = $databaseId; $apiParams['collectionId'] = $collectionId; $apiParams['documentId'] = $documentId; - $apiParams['data'] = $data; - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1798,6 +1898,9 @@ public function upsertDocument(string $databaseId, string $collectionId, string * @param ?array $permissions * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateRow` instead. + * @see Tables::updateRow */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null): array { @@ -1839,6 +1942,9 @@ public function updateDocument(string $databaseId, string $collectionId, string * @param string $documentId * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteRow` instead. + * @see Tables::deleteRow */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId): string { @@ -1875,6 +1981,9 @@ public function deleteDocument(string $databaseId, string $collectionId, string * @param ?float $min * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `decrementRowColumn` instead. + * @see Tables::decrementRowColumn */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null): array { @@ -1920,6 +2029,9 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio * @param ?float $max * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `incrementRowColumn` instead. + * @see Tables::incrementRowColumn */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null): array { @@ -1962,6 +2074,9 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio * @param ?array $queries * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `listIndexes` instead. + * @see Tables::listIndexes */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -2003,6 +2118,9 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu * @param ?array $lengths * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createIndex` instead. + * @see Tables::createIndex */ public function createIndex(string $databaseId, string $collectionId, string $key, IndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): array { @@ -2046,6 +2164,9 @@ public function createIndex(string $databaseId, string $collectionId, string $ke * @param string $key * @throws AppwriteException * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `getIndex` instead. + * @see Tables::getIndex */ public function getIndex(string $databaseId, string $collectionId, string $key): array { @@ -2078,6 +2199,9 @@ public function getIndex(string $databaseId, string $collectionId, string $key): * @param string $key * @throws AppwriteException * @return string + * + * @deprecated This API has been deprecated since 1.8.0. Please use `deleteIndex` instead. + * @see Tables::deleteIndex */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { diff --git a/src/Appwrite/Services/Tables.php b/src/Appwrite/Services/Tables.php new file mode 100644 index 0000000..88d9ffa --- /dev/null +++ b/src/Appwrite/Services/Tables.php @@ -0,0 +1,1906 @@ +client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new Table. Before using this route, you should create a new + * database resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param string $name + * @param ?array $permissions + * @param ?bool $rowSecurity + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function create(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{databaseId}'], + [$databaseId], + '/databases/{databaseId}/tables' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['name'] = $name; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($rowSecurity)) { + $apiParams['rowSecurity'] = $rowSecurity; + } + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a table by its unique ID. This endpoint response returns a JSON object + * with the table metadata. + * + * @param string $databaseId + * @param string $tableId + * @throws AppwriteException + * @return array + */ + public function get(string $databaseId, string $tableId): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a table by its unique ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $name + * @param ?array $permissions + * @param ?bool $rowSecurity + * @param ?bool $enabled + * @throws AppwriteException + * @return array + */ + public function update(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['name'] = $name; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + if (!is_null($rowSecurity)) { + $apiParams['rowSecurity'] = $rowSecurity; + } + + if (!is_null($enabled)) { + $apiParams['enabled'] = $enabled; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a table by its unique ID. Only users with write permissions have + * access to delete this resource. + * + * @param string $databaseId + * @param string $tableId + * @throws AppwriteException + * @return string + */ + public function delete(string $databaseId, string $tableId): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List attributes in the collection. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listColumns(string $databaseId, string $tableId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a boolean column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?bool $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/boolean' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a boolean column. Changing the `default` value will not update + * already existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?bool $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/boolean/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a date time column according to the ISO 8601 standard. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/datetime' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a date time column. Changing the `default` value will not update + * already existing rows. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/datetime/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an email column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/email' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an email column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/email/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an enumeration column. The `elements` param acts as a white-list of + * accepted values for this column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param array $elements + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/enum' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['elements'] = $elements; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an enum column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param array $elements + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/enum/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['elements'] = $elements; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a float column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?float $min + * @param ?float $max + * @param ?float $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/float' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a float column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?float $xdefault + * @param ?float $min + * @param ?float $max + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/float/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create an integer column. Optionally, minimum and maximum values can be + * provided. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?int $min + * @param ?int $max + * @param ?int $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/integer' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an integer column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?int $xdefault + * @param ?int $min + * @param ?int $max + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/integer/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create IP address column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/ip' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an ip column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/ip/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param string $databaseId + * @param string $tableId + * @param string $relatedTableId + * @param RelationshipType $type + * @param ?bool $twoWay + * @param ?string $key + * @param ?string $twoWayKey + * @param ?RelationMutate $onDelete + * @throws AppwriteException + * @return array + */ + public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/relationship' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['relatedTableId'] = $relatedTableId; + $apiParams['type'] = $type; + + if (!is_null($twoWay)) { + $apiParams['twoWay'] = $twoWay; + } + + if (!is_null($key)) { + $apiParams['key'] = $key; + } + + if (!is_null($twoWayKey)) { + $apiParams['twoWayKey'] = $twoWayKey; + } + + if (!is_null($onDelete)) { + $apiParams['onDelete'] = $onDelete; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a string column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param int $size + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @param ?bool $encrypt + * @throws AppwriteException + * @return array + */ + public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/string' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['size'] = $size; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + if (!is_null($encrypt)) { + $apiParams['encrypt'] = $encrypt; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a string column. Changing the `default` value will not update + * already existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?int $size + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/string/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($size)) { + $apiParams['size'] = $size; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a URL column. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?bool $xarray + * @throws AppwriteException + * @return array + */ + public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/columns/url' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + + if (!is_null($xdefault)) { + $apiParams['default'] = $xdefault; + } + + if (!is_null($xarray)) { + $apiParams['array'] = $xarray; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update an url column. Changing the `default` value will not update already + * existing rows. + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/url/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get column by ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return array + */ + public function getColumn(string $databaseId, string $tableId, string $key): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Deletes a column. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return string + */ + public function deleteColumn(string $databaseId, string $tableId, string $key): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update relationship column. [Learn more about relationship + * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). + * + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param ?RelationMutate $onDelete + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/columns/{key}/relationship' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + if (!is_null($onDelete)) { + $apiParams['onDelete'] = $onDelete; + } + + if (!is_null($newKey)) { + $apiParams['newKey'] = $newKey; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * List indexes in the collection. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listIndexes(string $databaseId, string $tableId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/indexes' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Creates an index on the attributes listed. Your index should include all + * the attributes you will query in a single request. + * Attributes can be `key`, `fulltext`, and `unique`. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param IndexType $type + * @param array $columns + * @param ?array $orders + * @param ?array $lengths + * @throws AppwriteException + * @return array + */ + public function createIndex(string $databaseId, string $tableId, string $key, IndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/indexes' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['type'] = $type; + $apiParams['columns'] = $columns; + + if (!is_null($orders)) { + $apiParams['orders'] = $orders; + } + + if (!is_null($lengths)) { + $apiParams['lengths'] = $lengths; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get index by ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return array + */ + public function getIndex(string $databaseId, string $tableId, string $key): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/indexes/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete an index. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @throws AppwriteException + * @return string + */ + public function deleteIndex(string $databaseId, string $tableId, string $key): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/databases/{databaseId}/tables/{tableId}/indexes/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a list of all the user's rows in a given table. You can use the query + * params to filter your results. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function listRows(string $databaseId, string $tableId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create a new Row. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param array $data + * @param ?array $permissions + * @throws AppwriteException + * @return array + */ + public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['data'] = $data; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create new Rows. Before using this route, you should create a new table + * resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param array $rows + * @throws AppwriteException + * @return array + */ + public function createRows(string $databaseId, string $tableId, array $rows): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rows'] = $rows; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create or update Rows. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * + * @param string $databaseId + * @param string $tableId + * @throws AppwriteException + * @return array + */ + public function upsertRows(string $databaseId, string $tableId): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update all rows that match your queries, if no queries are submitted then + * all rows are updated. You can pass only specific fields to be updated. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $data + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Bulk delete rows using queries, if no queries are passed then all rows are + * deleted. + * + * @param string $databaseId + * @param string $tableId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function deleteRows(string $databaseId, string $tableId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/databases/{databaseId}/tables/{tableId}/rows' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Get a row by its unique ID. This endpoint response returns a JSON object + * with the row data. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param ?array $queries + * @throws AppwriteException + * @return array + */ + public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/databases/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($queries)) { + $apiParams['queries'] = $queries; + } + + $apiHeaders = []; + + return $this->client->call( + Client::METHOD_GET, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Create or update a Row. Before using this route, you should create a new + * table resource using either a [server + * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) + * API or directly from your database console. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @throws AppwriteException + * @return array + */ + public function upsertRow(string $databaseId, string $tableId, string $rowId): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/databases/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PUT, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a row by its unique ID. Using the patch method you can pass only + * specific fields that will get updated. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param ?array $data + * @param ?array $permissions + * @throws AppwriteException + * @return array + */ + public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/databases/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + if (!is_null($data)) { + $apiParams['data'] = $data; + } + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Delete a row by its unique ID. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @throws AppwriteException + * @return string + */ + public function deleteRow(string $databaseId, string $tableId, string $rowId): string + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}'], + [$databaseId, $tableId, $rowId], + '/databases/{databaseId}/tables/{tableId}/rows/{rowId}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_DELETE, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Decrement a specific column of a row by a given value. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param string $column + * @param ?float $value + * @param ?float $min + * @throws AppwriteException + * @return array + */ + public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}', '{column}'], + [$databaseId, $tableId, $rowId, $column], + '/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['column'] = $column; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($min)) { + $apiParams['min'] = $min; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Increment a specific column of a row by a given value. + * + * @param string $databaseId + * @param string $tableId + * @param string $rowId + * @param string $column + * @param ?float $value + * @param ?float $max + * @throws AppwriteException + * @return array + */ + public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{rowId}', '{column}'], + [$databaseId, $tableId, $rowId, $column], + '/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['rowId'] = $rowId; + $apiParams['column'] = $column; + + if (!is_null($value)) { + $apiParams['value'] = $value; + } + + if (!is_null($max)) { + $apiParams['max'] = $max; + } + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_PATCH, + $apiPath, + $apiHeaders, + $apiParams + ); + } +} \ No newline at end of file diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index e870542..ef429e9 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -922,8 +922,7 @@ public function testMethodUpsertDocuments(): void { $response = $this->databases->upsertDocuments( "", - "", - array() + "" ); $this->assertSame($data, $response); @@ -1011,8 +1010,7 @@ public function testMethodUpsertDocument(): void { $response = $this->databases->upsertDocument( "", "", - "", - array() + "" ); $this->assertSame($data, $response); diff --git a/tests/Appwrite/Services/TablesTest.php b/tests/Appwrite/Services/TablesTest.php new file mode 100644 index 0000000..92ab33b --- /dev/null +++ b/tests/Appwrite/Services/TablesTest.php @@ -0,0 +1,1107 @@ +client = Mockery::mock(Client::class); + $this->tables = new Tables($this->client); + } + + public function testMethodList(): void { + + $data = array( + "total" => 5, + "tables" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->list( + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->create( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGet(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->get( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdate(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(), + "databaseId" => "5e5ea5c16897e", + "name" => "My Table", + "enabled" => true, + "rowSecurity" => true, + "columns" => array(), + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->update( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDelete(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->delete( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListColumns(): void { + + $data = array( + "total" => 5, + "columns" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->listColumns( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateBooleanColumn(): void { + + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createBooleanColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateBooleanColumn(): void { + + $data = array( + "key" => "isEnabled", + "type" => "boolean", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateBooleanColumn( + "", + "", + "", + true, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateDatetimeColumn(): void { + + $data = array( + "key" => "birthDay", + "type" => "datetime", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "datetime",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createDatetimeColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateDatetimeColumn(): void { + + $data = array( + "key" => "birthDay", + "type" => "datetime", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "datetime",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateDatetimeColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEmailColumn(): void { + + $data = array( + "key" => "userEmail", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createEmailColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEmailColumn(): void { + + $data = array( + "key" => "userEmail", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "email",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateEmailColumn( + "", + "", + "", + true, + "email@example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateEnumColumn(): void { + + $data = array( + "key" => "status", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "elements" => array(), + "format" => "enum",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createEnumColumn( + "", + "", + "", + array(), + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateEnumColumn(): void { + + $data = array( + "key" => "status", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "elements" => array(), + "format" => "enum",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateEnumColumn( + "", + "", + "", + array(), + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateFloatColumn(): void { + + $data = array( + "key" => "percentageCompleted", + "type" => "double", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createFloatColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateFloatColumn(): void { + + $data = array( + "key" => "percentageCompleted", + "type" => "double", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateFloatColumn( + "", + "", + "", + true, + 1.0 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIntegerColumn(): void { + + $data = array( + "key" => "count", + "type" => "integer", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createIntegerColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateIntegerColumn(): void { + + $data = array( + "key" => "count", + "type" => "integer", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateIntegerColumn( + "", + "", + "", + true, + 1 + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIpColumn(): void { + + $data = array( + "key" => "ipAddress", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "ip",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createIpColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateIpColumn(): void { + + $data = array( + "key" => "ipAddress", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "ip",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateIpColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRelationshipColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createRelationshipColumn( + "", + "", + "", + "oneToOne" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateStringColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createStringColumn( + "", + "", + "", + 1, + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateStringColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "size" => 128,); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateStringColumn( + "", + "", + "", + true, + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateUrlColumn(): void { + + $data = array( + "key" => "githubUrl", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "url",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createUrlColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateUrlColumn(): void { + + $data = array( + "key" => "githubUrl", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "format" => "url",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateUrlColumn( + "", + "", + "", + true, + "https://example.com" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetColumn(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->getColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteColumn(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->deleteColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRelationshipColumn(): void { + + $data = array( + "key" => "fullName", + "type" => "string", + "status" => "available", + "error" => "string", + "required" => true, + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "relatedTable" => "table", + "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", + "twoWay" => true, + "twoWayKey" => "string", + "onDelete" => "restrict|cascade|setNull", + "side" => "parent|child",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateRelationshipColumn( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListIndexes(): void { + + $data = array( + "total" => 5, + "indexes" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->listIndexes( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateIndex(): void { + + $data = array( + "key" => "index1", + "type" => "primary", + "status" => "available", + "error" => "string", + "columns" => array(), + "lengths" => array(), + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createIndex( + "", + "", + "", + "key", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetIndex(): void { + + $data = array( + "key" => "index1", + "type" => "primary", + "status" => "available", + "error" => "string", + "columns" => array(), + "lengths" => array(), + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->getIndex( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteIndex(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->deleteIndex( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodListRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->listRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createRow( + "", + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreateRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->createRows( + "", + "", + array() + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpsertRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->upsertRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteRows(): void { + + $data = array( + "total" => 5, + "rows" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->deleteRows( + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodGetRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->getRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpsertRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->upsertRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateRow(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->updateRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDeleteRow(): void { + + $data = ''; + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->deleteRow( + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodDecrementRowColumn(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->decrementRowColumn( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + + public function testMethodIncrementRowColumn(): void { + + $data = array( + "\$id" => "5e5ea5c16897e", + "\$sequence" => 1, + "\$tableId" => "5e5ea5c15117e", + "\$databaseId" => "5e5ea5c15117e", + "\$createdAt" => "2020-10-15T06:38:00.000+00:00", + "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", + "\$permissions" => array(),); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tables->incrementRowColumn( + "", + "", + "", + "" + ); + + $this->assertSame($data, $response); + } + +} From 69c92861e58cf9fb37449ee901a4d82a903e987f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 24 Jul 2025 06:43:01 +0000 Subject: [PATCH 3/4] chore: regen to 1.7.x --- README.md | 4 +- docs/databases.md | 103 +- docs/examples/databases/create-document.md | 5 +- docs/examples/databases/create-documents.md | 2 +- docs/examples/databases/upsert-document.md | 9 +- docs/examples/databases/upsert-documents.md | 5 +- docs/examples/tables/create-boolean-column.md | 20 - .../examples/tables/create-datetime-column.md | 20 - docs/examples/tables/create-email-column.md | 20 - docs/examples/tables/create-enum-column.md | 21 - docs/examples/tables/create-float-column.md | 22 - docs/examples/tables/create-index.md | 22 - docs/examples/tables/create-integer-column.md | 22 - docs/examples/tables/create-ip-column.md | 20 - .../tables/create-relationship-column.md | 23 - docs/examples/tables/create-row.md | 20 - docs/examples/tables/create-rows.md | 17 - docs/examples/tables/create-string-column.md | 22 - docs/examples/tables/create-url-column.md | 20 - docs/examples/tables/create.md | 20 - docs/examples/tables/decrement-row-column.md | 20 - docs/examples/tables/delete-column.md | 17 - docs/examples/tables/delete-index.md | 17 - docs/examples/tables/delete-row.md | 17 - docs/examples/tables/delete-rows.md | 17 - docs/examples/tables/delete.md | 16 - docs/examples/tables/get-column.md | 17 - docs/examples/tables/get-index.md | 17 - docs/examples/tables/get-row.md | 18 - docs/examples/tables/get.md | 16 - docs/examples/tables/increment-row-column.md | 20 - docs/examples/tables/list-columns.md | 17 - docs/examples/tables/list-indexes.md | 17 - docs/examples/tables/list-rows.md | 17 - docs/examples/tables/list.md | 17 - docs/examples/tables/update-boolean-column.md | 20 - .../examples/tables/update-datetime-column.md | 20 - docs/examples/tables/update-email-column.md | 20 - docs/examples/tables/update-enum-column.md | 21 - docs/examples/tables/update-float-column.md | 22 - docs/examples/tables/update-integer-column.md | 22 - docs/examples/tables/update-ip-column.md | 20 - .../tables/update-relationship-column.md | 19 - docs/examples/tables/update-row.md | 19 - docs/examples/tables/update-rows.md | 18 - docs/examples/tables/update-string-column.md | 21 - docs/examples/tables/update-url-column.md | 20 - docs/examples/tables/update.md | 20 - docs/examples/tables/upsert-row.md | 18 - docs/examples/tables/upsert-rows.md | 16 - docs/tables.md | 773 ------- src/Appwrite/Client.php | 6 +- src/Appwrite/Services/Account.php | 4 - src/Appwrite/Services/Databases.php | 149 +- src/Appwrite/Services/Tables.php | 1906 ----------------- tests/Appwrite/Services/DatabasesTest.php | 6 +- tests/Appwrite/Services/TablesTest.php | 1107 ---------- 57 files changed, 86 insertions(+), 4838 deletions(-) delete mode 100644 docs/examples/tables/create-boolean-column.md delete mode 100644 docs/examples/tables/create-datetime-column.md delete mode 100644 docs/examples/tables/create-email-column.md delete mode 100644 docs/examples/tables/create-enum-column.md delete mode 100644 docs/examples/tables/create-float-column.md delete mode 100644 docs/examples/tables/create-index.md delete mode 100644 docs/examples/tables/create-integer-column.md delete mode 100644 docs/examples/tables/create-ip-column.md delete mode 100644 docs/examples/tables/create-relationship-column.md delete mode 100644 docs/examples/tables/create-row.md delete mode 100644 docs/examples/tables/create-rows.md delete mode 100644 docs/examples/tables/create-string-column.md delete mode 100644 docs/examples/tables/create-url-column.md delete mode 100644 docs/examples/tables/create.md delete mode 100644 docs/examples/tables/decrement-row-column.md delete mode 100644 docs/examples/tables/delete-column.md delete mode 100644 docs/examples/tables/delete-index.md delete mode 100644 docs/examples/tables/delete-row.md delete mode 100644 docs/examples/tables/delete-rows.md delete mode 100644 docs/examples/tables/delete.md delete mode 100644 docs/examples/tables/get-column.md delete mode 100644 docs/examples/tables/get-index.md delete mode 100644 docs/examples/tables/get-row.md delete mode 100644 docs/examples/tables/get.md delete mode 100644 docs/examples/tables/increment-row-column.md delete mode 100644 docs/examples/tables/list-columns.md delete mode 100644 docs/examples/tables/list-indexes.md delete mode 100644 docs/examples/tables/list-rows.md delete mode 100644 docs/examples/tables/list.md delete mode 100644 docs/examples/tables/update-boolean-column.md delete mode 100644 docs/examples/tables/update-datetime-column.md delete mode 100644 docs/examples/tables/update-email-column.md delete mode 100644 docs/examples/tables/update-enum-column.md delete mode 100644 docs/examples/tables/update-float-column.md delete mode 100644 docs/examples/tables/update-integer-column.md delete mode 100644 docs/examples/tables/update-ip-column.md delete mode 100644 docs/examples/tables/update-relationship-column.md delete mode 100644 docs/examples/tables/update-row.md delete mode 100644 docs/examples/tables/update-rows.md delete mode 100644 docs/examples/tables/update-string-column.md delete mode 100644 docs/examples/tables/update-url-column.md delete mode 100644 docs/examples/tables/update.md delete mode 100644 docs/examples/tables/upsert-row.md delete mode 100644 docs/examples/tables/upsert-rows.md delete mode 100644 docs/tables.md delete mode 100644 src/Appwrite/Services/Tables.php delete mode 100644 tests/Appwrite/Services/TablesTest.php diff --git a/README.md b/README.md index 3fc6168..382a055 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Appwrite PHP SDK ![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1) -![Version](https://img.shields.io/badge/api%20version-1.8.0-blue.svg?style=flat-square&v=1) +![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square&v=1) [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) -**This SDK is compatible with Appwrite server version 1.8.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** +**This SDK is compatible with Appwrite server version 1.7.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).** Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) diff --git a/docs/databases.md b/docs/databases.md index a4a7104..acca9fc 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -162,7 +162,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error | [] | @@ -178,7 +178,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | boolean | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -196,7 +196,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | boolean | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -214,7 +214,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#createCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for the attribute in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when attribute is required. | | @@ -232,7 +232,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -251,7 +251,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -270,18 +270,18 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New Attribute Key. | | +| newKey | string | New attribute key. | | ```http request POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/enum ``` -** Create an enum attribute. The `elements` param acts as a white-list of accepted values for this attribute. +** Create an enumeration attribute. The `elements` param acts as a white-list of accepted values for this attribute. ** ### Parameters @@ -289,9 +289,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | -| elements | array | Array of enum values. | | +| elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -309,12 +309,12 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | -| elements | array | Updated list of enum values. | | +| elements | array | Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 255 characters long. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New Attribute Key. | | +| newKey | string | New attribute key. | | ```http request @@ -329,12 +329,12 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| min | number | Minimum value. | | -| max | number | Maximum value. | | -| default | number | Default value. Cannot be set when required. | | +| min | number | Minimum value to enforce on new documents | | +| max | number | Maximum value to enforce on new documents | | +| default | number | Default value for attribute when not provided. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -350,13 +350,13 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| min | number | Minimum value. | | -| max | number | Maximum value. | | -| default | number | Default value. Cannot be set when required. | | -| newKey | string | New Attribute Key. | | +| min | number | Minimum value to enforce on new documents | | +| max | number | Maximum value to enforce on new documents | | +| default | number | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| newKey | string | New attribute key. | | ```http request @@ -371,12 +371,12 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| min | integer | Minimum value | | -| max | integer | Maximum value | | -| default | integer | Default value. Cannot be set when attribute is required. | | +| min | integer | Minimum value to enforce on new documents | | +| max | integer | Maximum value to enforce on new documents | | +| default | integer | Default value for attribute when not provided. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -392,13 +392,13 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| min | integer | Minimum value | | -| max | integer | Maximum value | | -| default | integer | Default value. Cannot be set when attribute is required. | | -| newKey | string | New Attribute Key. | | +| min | integer | Minimum value to enforce on new documents | | +| max | integer | Maximum value to enforce on new documents | | +| default | integer | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| newKey | string | New attribute key. | | ```http request @@ -413,10 +413,10 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value. Cannot be set when attribute is required. | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | | array | boolean | Is attribute an array? | | @@ -432,11 +432,11 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | -| default | string | Default value. Cannot be set when attribute is required. | | -| newKey | string | New Attribute Key. | | +| default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | +| newKey | string | New attribute key. | | ```http request @@ -451,8 +451,8 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | -| relatedCollectionId | string | Related Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| relatedCollectionId | string | Related Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | type | string | Relation type | | | twoWay | boolean | Is Two Way? | | | key | string | Attribute Key. | | @@ -472,7 +472,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | size | integer | Attribute size for text attributes, in number of characters. | | | required | boolean | Is attribute required? | | @@ -493,12 +493,12 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | | size | integer | Maximum size of the string attribute. | | -| newKey | string | New Attribute Key. | | +| newKey | string | New attribute key. | | ```http request @@ -513,7 +513,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | @@ -532,11 +532,11 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | required | boolean | Is attribute required? | | | default | string | Default value for attribute when not provided. Cannot be set when attribute is required. | | -| newKey | string | New Attribute Key. | | +| newKey | string | New attribute key. | | ```http request @@ -550,7 +550,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | @@ -565,7 +565,7 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | @@ -581,10 +581,10 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | Field Name | Type | Description | Default | | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | -| collectionId | string | **Required** Collection ID. | | +| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | | | key | string | **Required** Attribute Key. | | | onDelete | string | Constraints option | | -| newKey | string | New Attribute Key. | | +| newKey | string | New attribute key. | | ```http request @@ -651,6 +651,7 @@ Create or update Documents. Before using this route, you should create a new col | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | +| documents | array | Array of document data as JSON objects. May contain partial documents. | | ```http request @@ -719,6 +720,8 @@ Create or update a Document. Before using this route, you should create a new co | databaseId | string | **Required** Database ID. | | | collectionId | string | **Required** Collection ID. | | | documentId | string | **Required** Document ID. | | +| data | object | Document data as JSON object. Include all required attributes of the document to be created or updated. | {} | +| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | ```http request @@ -767,7 +770,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | collectionId | string | **Required** Collection ID. | | | documentId | string | **Required** Document ID. | | | attribute | string | **Required** Attribute key. | | -| value | number | Value to increment the attribute by. The value must be a number. | 1 | +| value | number | Value to decrement the attribute by. The value must be a number. | 1 | | min | number | Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. | | diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index 8726b37..bf1ee3f 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -5,9 +5,8 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setKey('') // Your secret API key - ->setJWT(''); // Your secret JSON Web Token + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); diff --git a/docs/examples/databases/create-documents.md b/docs/examples/databases/create-documents.md index 9429b57..bc05f67 100644 --- a/docs/examples/databases/create-documents.md +++ b/docs/examples/databases/create-documents.md @@ -5,7 +5,7 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setAdmin('') // + ->setProject('') // Your project ID ->setKey(''); // Your secret API key $databases = new Databases($client); diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md index 2f8464c..6cff829 100644 --- a/docs/examples/databases/upsert-document.md +++ b/docs/examples/databases/upsert-document.md @@ -5,14 +5,15 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setKey('') // Your secret API key - ->setJWT(''); // Your secret JSON Web Token + ->setProject('') // Your project ID + ->setSession(''); // The user session to authenticate with $databases = new Databases($client); $result = $databases->upsertDocument( databaseId: '', collectionId: '', - documentId: '' + documentId: '', + data: [], + permissions: ["read("any")"] // optional ); \ No newline at end of file diff --git a/docs/examples/databases/upsert-documents.md b/docs/examples/databases/upsert-documents.md index 11898dc..d9f9efd 100644 --- a/docs/examples/databases/upsert-documents.md +++ b/docs/examples/databases/upsert-documents.md @@ -5,12 +5,13 @@ use Appwrite\Services\Databases; $client = (new Client()) ->setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setAdmin('') // + ->setProject('') // Your project ID ->setKey(''); // Your secret API key $databases = new Databases($client); $result = $databases->upsertDocuments( databaseId: '', - collectionId: '' + collectionId: '', + documents: [] ); \ No newline at end of file diff --git a/docs/examples/tables/create-boolean-column.md b/docs/examples/tables/create-boolean-column.md deleted file mode 100644 index 2833975..0000000 --- a/docs/examples/tables/create-boolean-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createBooleanColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: false, // optional - array: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-datetime-column.md b/docs/examples/tables/create-datetime-column.md deleted file mode 100644 index d7f18f2..0000000 --- a/docs/examples/tables/create-datetime-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createDatetimeColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: '', // optional - array: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-email-column.md b/docs/examples/tables/create-email-column.md deleted file mode 100644 index 15ec2cf..0000000 --- a/docs/examples/tables/create-email-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createEmailColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: 'email@example.com', // optional - array: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-enum-column.md b/docs/examples/tables/create-enum-column.md deleted file mode 100644 index aa2b613..0000000 --- a/docs/examples/tables/create-enum-column.md +++ /dev/null @@ -1,21 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createEnumColumn( - databaseId: '', - tableId: '', - key: '', - elements: [], - required: false, - default: '', // optional - array: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-float-column.md b/docs/examples/tables/create-float-column.md deleted file mode 100644 index 1f620dc..0000000 --- a/docs/examples/tables/create-float-column.md +++ /dev/null @@ -1,22 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createFloatColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - min: null, // optional - max: null, // optional - default: null, // optional - array: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-index.md b/docs/examples/tables/create-index.md deleted file mode 100644 index 9844e04..0000000 --- a/docs/examples/tables/create-index.md +++ /dev/null @@ -1,22 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createIndex( - databaseId: '', - tableId: '', - key: '', - type: IndexType::KEY(), - columns: [], - orders: [], // optional - lengths: [] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-integer-column.md b/docs/examples/tables/create-integer-column.md deleted file mode 100644 index 185f12c..0000000 --- a/docs/examples/tables/create-integer-column.md +++ /dev/null @@ -1,22 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createIntegerColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - min: null, // optional - max: null, // optional - default: null, // optional - array: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-ip-column.md b/docs/examples/tables/create-ip-column.md deleted file mode 100644 index 1f74e4d..0000000 --- a/docs/examples/tables/create-ip-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createIpColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: '', // optional - array: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-relationship-column.md b/docs/examples/tables/create-relationship-column.md deleted file mode 100644 index c86b4c5..0000000 --- a/docs/examples/tables/create-relationship-column.md +++ /dev/null @@ -1,23 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createRelationshipColumn( - databaseId: '', - tableId: '', - relatedTableId: '', - type: RelationshipType::ONETOONE(), - twoWay: false, // optional - key: '', // optional - twoWayKey: '', // optional - onDelete: RelationMutate::CASCADE() // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-row.md b/docs/examples/tables/create-row.md deleted file mode 100644 index 6b64a7e..0000000 --- a/docs/examples/tables/create-row.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setKey('') // Your secret API key - ->setJWT(''); // Your secret JSON Web Token - -$tables = new Tables($client); - -$result = $tables->createRow( - databaseId: '', - tableId: '', - rowId: '', - data: [], - permissions: ["read("any")"] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-rows.md b/docs/examples/tables/create-rows.md deleted file mode 100644 index a1bf72a..0000000 --- a/docs/examples/tables/create-rows.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setAdmin('') // - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createRows( - databaseId: '', - tableId: '', - rows: [] -); \ No newline at end of file diff --git a/docs/examples/tables/create-string-column.md b/docs/examples/tables/create-string-column.md deleted file mode 100644 index 085aff2..0000000 --- a/docs/examples/tables/create-string-column.md +++ /dev/null @@ -1,22 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createStringColumn( - databaseId: '', - tableId: '', - key: '', - size: 1, - required: false, - default: '', // optional - array: false, // optional - encrypt: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create-url-column.md b/docs/examples/tables/create-url-column.md deleted file mode 100644 index d0bdb55..0000000 --- a/docs/examples/tables/create-url-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->createUrlColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: 'https://example.com', // optional - array: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/create.md b/docs/examples/tables/create.md deleted file mode 100644 index 773d7a2..0000000 --- a/docs/examples/tables/create.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->create( - databaseId: '', - tableId: '', - name: '', - permissions: ["read("any")"], // optional - rowSecurity: false, // optional - enabled: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/decrement-row-column.md b/docs/examples/tables/decrement-row-column.md deleted file mode 100644 index b0c44b6..0000000 --- a/docs/examples/tables/decrement-row-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->decrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - value: null, // optional - min: null // optional -); \ No newline at end of file diff --git a/docs/examples/tables/delete-column.md b/docs/examples/tables/delete-column.md deleted file mode 100644 index 9bd6738..0000000 --- a/docs/examples/tables/delete-column.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->deleteColumn( - databaseId: '', - tableId: '', - key: '' -); \ No newline at end of file diff --git a/docs/examples/tables/delete-index.md b/docs/examples/tables/delete-index.md deleted file mode 100644 index bbd7484..0000000 --- a/docs/examples/tables/delete-index.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->deleteIndex( - databaseId: '', - tableId: '', - key: '' -); \ No newline at end of file diff --git a/docs/examples/tables/delete-row.md b/docs/examples/tables/delete-row.md deleted file mode 100644 index 0c4ab6e..0000000 --- a/docs/examples/tables/delete-row.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with - -$tables = new Tables($client); - -$result = $tables->deleteRow( - databaseId: '', - tableId: '', - rowId: '' -); \ No newline at end of file diff --git a/docs/examples/tables/delete-rows.md b/docs/examples/tables/delete-rows.md deleted file mode 100644 index b0c984c..0000000 --- a/docs/examples/tables/delete-rows.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->deleteRows( - databaseId: '', - tableId: '', - queries: [] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/delete.md b/docs/examples/tables/delete.md deleted file mode 100644 index f145eed..0000000 --- a/docs/examples/tables/delete.md +++ /dev/null @@ -1,16 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->delete( - databaseId: '', - tableId: '' -); \ No newline at end of file diff --git a/docs/examples/tables/get-column.md b/docs/examples/tables/get-column.md deleted file mode 100644 index b8b6765..0000000 --- a/docs/examples/tables/get-column.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->getColumn( - databaseId: '', - tableId: '', - key: '' -); \ No newline at end of file diff --git a/docs/examples/tables/get-index.md b/docs/examples/tables/get-index.md deleted file mode 100644 index 5d1139d..0000000 --- a/docs/examples/tables/get-index.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->getIndex( - databaseId: '', - tableId: '', - key: '' -); \ No newline at end of file diff --git a/docs/examples/tables/get-row.md b/docs/examples/tables/get-row.md deleted file mode 100644 index ccde387..0000000 --- a/docs/examples/tables/get-row.md +++ /dev/null @@ -1,18 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with - -$tables = new Tables($client); - -$result = $tables->getRow( - databaseId: '', - tableId: '', - rowId: '', - queries: [] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/get.md b/docs/examples/tables/get.md deleted file mode 100644 index d07ef73..0000000 --- a/docs/examples/tables/get.md +++ /dev/null @@ -1,16 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->get( - databaseId: '', - tableId: '' -); \ No newline at end of file diff --git a/docs/examples/tables/increment-row-column.md b/docs/examples/tables/increment-row-column.md deleted file mode 100644 index aa5a3c0..0000000 --- a/docs/examples/tables/increment-row-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->incrementRowColumn( - databaseId: '', - tableId: '', - rowId: '', - column: '', - value: null, // optional - max: null // optional -); \ No newline at end of file diff --git a/docs/examples/tables/list-columns.md b/docs/examples/tables/list-columns.md deleted file mode 100644 index 0338567..0000000 --- a/docs/examples/tables/list-columns.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->listColumns( - databaseId: '', - tableId: '', - queries: [] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/list-indexes.md b/docs/examples/tables/list-indexes.md deleted file mode 100644 index df1f8c6..0000000 --- a/docs/examples/tables/list-indexes.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->listIndexes( - databaseId: '', - tableId: '', - queries: [] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/list-rows.md b/docs/examples/tables/list-rows.md deleted file mode 100644 index 2041d72..0000000 --- a/docs/examples/tables/list-rows.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with - -$tables = new Tables($client); - -$result = $tables->listRows( - databaseId: '', - tableId: '', - queries: [] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/list.md b/docs/examples/tables/list.md deleted file mode 100644 index 37df0a4..0000000 --- a/docs/examples/tables/list.md +++ /dev/null @@ -1,17 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->list( - databaseId: '', - queries: [], // optional - search: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-boolean-column.md b/docs/examples/tables/update-boolean-column.md deleted file mode 100644 index 8ad8050..0000000 --- a/docs/examples/tables/update-boolean-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateBooleanColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: false, - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-datetime-column.md b/docs/examples/tables/update-datetime-column.md deleted file mode 100644 index 5185357..0000000 --- a/docs/examples/tables/update-datetime-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateDatetimeColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: '', - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-email-column.md b/docs/examples/tables/update-email-column.md deleted file mode 100644 index 7acbb81..0000000 --- a/docs/examples/tables/update-email-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateEmailColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: 'email@example.com', - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-enum-column.md b/docs/examples/tables/update-enum-column.md deleted file mode 100644 index 478905a..0000000 --- a/docs/examples/tables/update-enum-column.md +++ /dev/null @@ -1,21 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateEnumColumn( - databaseId: '', - tableId: '', - key: '', - elements: [], - required: false, - default: '', - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-float-column.md b/docs/examples/tables/update-float-column.md deleted file mode 100644 index 1d9c5fd..0000000 --- a/docs/examples/tables/update-float-column.md +++ /dev/null @@ -1,22 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateFloatColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: null, - min: null, // optional - max: null, // optional - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-integer-column.md b/docs/examples/tables/update-integer-column.md deleted file mode 100644 index f6998db..0000000 --- a/docs/examples/tables/update-integer-column.md +++ /dev/null @@ -1,22 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateIntegerColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: null, - min: null, // optional - max: null, // optional - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-ip-column.md b/docs/examples/tables/update-ip-column.md deleted file mode 100644 index e7906fb..0000000 --- a/docs/examples/tables/update-ip-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateIpColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: '', - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-relationship-column.md b/docs/examples/tables/update-relationship-column.md deleted file mode 100644 index d6505c7..0000000 --- a/docs/examples/tables/update-relationship-column.md +++ /dev/null @@ -1,19 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateRelationshipColumn( - databaseId: '', - tableId: '', - key: '', - onDelete: RelationMutate::CASCADE(), // optional - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-row.md b/docs/examples/tables/update-row.md deleted file mode 100644 index 921c43d..0000000 --- a/docs/examples/tables/update-row.md +++ /dev/null @@ -1,19 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setSession(''); // The user session to authenticate with - -$tables = new Tables($client); - -$result = $tables->updateRow( - databaseId: '', - tableId: '', - rowId: '', - data: [], // optional - permissions: ["read("any")"] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-rows.md b/docs/examples/tables/update-rows.md deleted file mode 100644 index f61fa2b..0000000 --- a/docs/examples/tables/update-rows.md +++ /dev/null @@ -1,18 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateRows( - databaseId: '', - tableId: '', - data: [], // optional - queries: [] // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-string-column.md b/docs/examples/tables/update-string-column.md deleted file mode 100644 index 8856ec1..0000000 --- a/docs/examples/tables/update-string-column.md +++ /dev/null @@ -1,21 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateStringColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: '', - size: 1, // optional - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update-url-column.md b/docs/examples/tables/update-url-column.md deleted file mode 100644 index faa46d1..0000000 --- a/docs/examples/tables/update-url-column.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->updateUrlColumn( - databaseId: '', - tableId: '', - key: '', - required: false, - default: 'https://example.com', - newKey: '' // optional -); \ No newline at end of file diff --git a/docs/examples/tables/update.md b/docs/examples/tables/update.md deleted file mode 100644 index 39f076b..0000000 --- a/docs/examples/tables/update.md +++ /dev/null @@ -1,20 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setProject('') // Your project ID - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->update( - databaseId: '', - tableId: '', - name: '', - permissions: ["read("any")"], // optional - rowSecurity: false, // optional - enabled: false // optional -); \ No newline at end of file diff --git a/docs/examples/tables/upsert-row.md b/docs/examples/tables/upsert-row.md deleted file mode 100644 index 2bddd9b..0000000 --- a/docs/examples/tables/upsert-row.md +++ /dev/null @@ -1,18 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setSession('') // The user session to authenticate with - ->setKey('') // Your secret API key - ->setJWT(''); // Your secret JSON Web Token - -$tables = new Tables($client); - -$result = $tables->upsertRow( - databaseId: '', - tableId: '', - rowId: '' -); \ No newline at end of file diff --git a/docs/examples/tables/upsert-rows.md b/docs/examples/tables/upsert-rows.md deleted file mode 100644 index 5ed5f02..0000000 --- a/docs/examples/tables/upsert-rows.md +++ /dev/null @@ -1,16 +0,0 @@ -setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint - ->setAdmin('') // - ->setKey(''); // Your secret API key - -$tables = new Tables($client); - -$result = $tables->upsertRows( - databaseId: '', - tableId: '' -); \ No newline at end of file diff --git a/docs/tables.md b/docs/tables.md deleted file mode 100644 index 4de77e4..0000000 --- a/docs/tables.md +++ /dev/null @@ -1,773 +0,0 @@ -# Tables Service - - -```http request -GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables -``` - -** Get a list of all tables that belong to the provided databaseId. You can use the search parameter to filter your results. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, rowSecurity | [] | -| search | string | Search term to filter your list results. Max length: 256 chars. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables -``` - -** Create a new Table. Before using this route, you should create a new database resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | -| name | string | Table name. Max length: 128 chars. | | -| permissions | array | An array of permissions strings. By default, no user is granted with any permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | -| rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a row. [Learn more about permissions](https://appwrite.io/docs/permissions). | | -| enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | - - -```http request -GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId} -``` - -** Get a table by its unique ID. This endpoint response returns a JSON object with the table metadata. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | - - -```http request -PUT https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId} -``` - -** Update a table by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| name | string | Table name. Max length: 128 chars. | | -| permissions | array | An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | -| rowSecurity | boolean | Enables configuring permissions for individual rows. A user needs one of row or table level permissions to access a document. [Learn more about permissions](https://appwrite.io/docs/permissions). | | -| enabled | boolean | Is table enabled? When set to 'disabled', users cannot access the table but Server SDKs with and API key can still read and write to the table. No data is lost when this is toggled. | 1 | - - -```http request -DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId} -``` - -** Delete a table by its unique ID. Only users with write permissions have access to delete this resource. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | - - -```http request -GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns -``` - -** List attributes in the collection. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, size, required, array, status, error | [] | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/boolean -``` - -** Create a boolean column. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| key | string | Column Key. | | -| required | boolean | Is column required? | | -| default | boolean | Default value for column when not provided. Cannot be set when column is required. | | -| array | boolean | Is column an array? | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/boolean/{key} -``` - -** Update a boolean column. Changing the `default` value will not update already existing rows. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| key | string | **Required** Column Key. | | -| required | boolean | Is column required? | | -| default | boolean | Default value for column when not provided. Cannot be set when column is required. | | -| newKey | string | New Column Key. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/datetime -``` - -** Create a date time column according to the ISO 8601 standard. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value for the column in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Cannot be set when column is required. | | -| array | boolean | Is column an array? | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/datetime/{key} -``` - -** Update a date time column. Changing the `default` value will not update already existing rows. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| newKey | string | New Column Key. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/email -``` - -** Create an email column. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| array | boolean | Is column an array? | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/email/{key} -``` - -** Update an email column. Changing the `default` value will not update already existing rows. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| newKey | string | New Column Key. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/enum -``` - -** Create an enumeration column. The `elements` param acts as a white-list of accepted values for this column. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | Column Key. | | -| elements | array | Array of enum values. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| array | boolean | Is column an array? | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/enum/{key} -``` - -** Update an enum column. Changing the `default` value will not update already existing rows. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| elements | array | Updated list of enum values. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| newKey | string | New Column Key. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/float -``` - -** Create a float column. Optionally, minimum and maximum values can be provided. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | Column Key. | | -| required | boolean | Is column required? | | -| min | number | Minimum value | | -| max | number | Maximum value | | -| default | number | Default value. Cannot be set when required. | | -| array | boolean | Is column an array? | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/float/{key} -``` - -** Update a float column. Changing the `default` value will not update already existing rows. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| required | boolean | Is column required? | | -| min | number | Minimum value | | -| max | number | Maximum value | | -| default | number | Default value. Cannot be set when required. | | -| newKey | string | New Column Key. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/integer -``` - -** Create an integer column. Optionally, minimum and maximum values can be provided. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | Column Key. | | -| required | boolean | Is column required? | | -| min | integer | Minimum value | | -| max | integer | Maximum value | | -| default | integer | Default value. Cannot be set when column is required. | | -| array | boolean | Is column an array? | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/integer/{key} -``` - -** Update an integer column. Changing the `default` value will not update already existing rows. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| required | boolean | Is column required? | | -| min | integer | Minimum value | | -| max | integer | Maximum value | | -| default | integer | Default value. Cannot be set when column is required. | | -| newKey | string | New Column Key. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/ip -``` - -** Create IP address column. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value. Cannot be set when column is required. | | -| array | boolean | Is column an array? | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/ip/{key} -``` - -** Update an ip column. Changing the `default` value will not update already existing rows. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value. Cannot be set when column is required. | | -| newKey | string | New Column Key. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/relationship -``` - -** Create relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| relatedTableId | string | Related Table ID. | | -| type | string | Relation type | | -| twoWay | boolean | Is Two Way? | | -| key | string | Column Key. | | -| twoWayKey | string | Two Way Column Key. | | -| onDelete | string | Constraints option | restrict | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/string -``` - -** Create a string column. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| key | string | Column Key. | | -| size | integer | Attribute size for text attributes, in number of characters. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| array | boolean | Is column an array? | | -| encrypt | boolean | Toggle encryption for the column. Encryption enhances security by not storing any plain text values in the database. However, encrypted columns cannot be queried. | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/string/{key} -``` - -** Update a string column. Changing the `default` value will not update already existing rows. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| key | string | **Required** Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| size | integer | Maximum size of the string column. | | -| newKey | string | New Column Key. | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/url -``` - -** Create a URL column. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| array | boolean | Is column an array? | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/url/{key} -``` - -** Update an url column. Changing the `default` value will not update already existing rows. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| required | boolean | Is column required? | | -| default | string | Default value for column when not provided. Cannot be set when column is required. | | -| newKey | string | New Column Key. | | - - -```http request -GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/{key} -``` - -** Get column by ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | - - -```http request -DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/{key} -``` - -** Deletes a column. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/columns/{key}/relationship -``` - -** Update relationship column. [Learn more about relationship columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| key | string | **Required** Column Key. | | -| onDelete | string | Constraints option | | -| newKey | string | New Column Key. | | - - -```http request -GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/indexes -``` - -** List indexes in the collection. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: key, type, status, attributes, error | [] | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/indexes -``` - -** Creates an index on the attributes listed. Your index should include all the attributes you will query in a single request. -Attributes can be `key`, `fulltext`, and `unique`. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| key | string | Index Key. | | -| type | string | Index type. | | -| columns | array | Array of columns to index. Maximum of 100 columns are allowed, each 32 characters long. | | -| orders | array | Array of index orders. Maximum of 100 orders are allowed. | [] | -| lengths | array | Length of index. Maximum of 100 | [] | - - -```http request -GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/indexes/{key} -``` - -** Get index by ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| key | string | **Required** Index Key. | | - - -```http request -DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/indexes/{key} -``` - -** Delete an index. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| key | string | **Required** Index Key. | | - - -```http request -GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows -``` - -** Get a list of all the user's rows in a given table. You can use the query params to filter your results. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows -``` - -** Create a new Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. | | -| rowId | string | Row ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | | -| data | object | Row data as JSON object. | {} | -| permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | | - - -```http request -POST https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows -``` - -** Create new Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). Make sure to define columns before creating rows. | | -| rows | array | Array of documents data as JSON objects. | [] | - - -```http request -PUT https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows -``` - -** Create or update Rows. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. - ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows -``` - -** Update all rows that match your queries, if no queries are submitted then all rows are updated. You can pass only specific fields to be updated. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| data | object | Row data as JSON object. Include only column and value pairs to be updated. | {} | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | - - -```http request -DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows -``` - -** Bulk delete rows using queries, if no queries are passed then all rows are deleted. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | - - -```http request -GET https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId} -``` - -** Get a row by its unique ID. This endpoint response returns a JSON object with the row data. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| rowId | string | **Required** Row ID. | | -| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] | - - -```http request -PUT https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId} -``` - -** Create or update a Row. Before using this route, you should create a new table resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateTable) API or directly from your database console. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| rowId | string | **Required** Row ID. | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId} -``` - -** Update a row by its unique ID. Using the patch method you can pass only specific fields that will get updated. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| rowId | string | **Required** Row ID. | | -| data | object | Row data as JSON object. Include only columns and value pairs to be updated. | {} | -| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | | - - -```http request -DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId} -``` - -** Delete a row by its unique ID. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tables#tablesCreate). | | -| rowId | string | **Required** Row ID. | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement -``` - -** Decrement a specific column of a row by a given value. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| rowId | string | **Required** Row ID. | | -| column | string | **Required** Column key. | | -| value | number | Value to increment the column by. The value must be a number. | 1 | -| min | number | Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. | | - - -```http request -PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment -``` - -** Increment a specific column of a row by a given value. ** - -### Parameters - -| Field Name | Type | Description | Default | -| --- | --- | --- | --- | -| databaseId | string | **Required** Database ID. | | -| tableId | string | **Required** Table ID. | | -| rowId | string | **Required** Row ID. | | -| column | string | **Required** Column key. | | -| value | number | Value to increment the column by. The value must be a number. | 1 | -| max | number | Maximum value for the column. If the current value is greater than this value, an error will be thrown. | | - diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 5c1c208..27f8cca 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/16.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/15.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '16.0.0', + 'x-sdk-version'=> '15.0.0', ]; /** @@ -49,7 +49,7 @@ class Client */ public function __construct() { - $this->headers['X-Appwrite-Response-Format'] = '1.8.0'; + $this->headers['X-Appwrite-Response-Format'] = '1.7.0'; } diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index 92257b8..13c7d7f 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -923,8 +923,6 @@ public function createEmailPasswordSession(string $email, string $password): arr * @param string $secret * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated. */ public function updateMagicURLSession(string $userId, string $secret): array { @@ -958,8 +956,6 @@ public function updateMagicURLSession(string $userId, string $secret): array * @param string $secret * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated. */ public function updatePhoneSession(string $userId, string $secret): array { diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 7b34e8b..19cfdbd 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -195,9 +195,6 @@ public function delete(string $databaseId): string * @param ?string $search * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `list` instead. - * @see Tables::list */ public function listCollections(string $databaseId, ?array $queries = null, ?string $search = null): array { @@ -242,9 +239,6 @@ public function listCollections(string $databaseId, ?array $queries = null, ?str * @param ?bool $enabled * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `create` instead. - * @see Tables::create */ public function createCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): array { @@ -290,9 +284,6 @@ public function createCollection(string $databaseId, string $collectionId, strin * @param string $collectionId * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `get` instead. - * @see Tables::get */ public function getCollection(string $databaseId, string $collectionId): array { @@ -327,9 +318,6 @@ public function getCollection(string $databaseId, string $collectionId): array * @param ?bool $enabled * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `update` instead. - * @see Tables::update */ public function updateCollection(string $databaseId, string $collectionId, string $name, ?array $permissions = null, ?bool $documentSecurity = null, ?bool $enabled = null): array { @@ -375,9 +363,6 @@ public function updateCollection(string $databaseId, string $collectionId, strin * @param string $collectionId * @throws AppwriteException * @return string - * - * @deprecated This API has been deprecated since 1.8.0. Please use `delete` instead. - * @see Tables::delete */ public function deleteCollection(string $databaseId, string $collectionId): string { @@ -410,9 +395,6 @@ public function deleteCollection(string $databaseId, string $collectionId): stri * @param ?array $queries * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `listColumns` instead. - * @see Tables::listColumns */ public function listAttributes(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -452,9 +434,6 @@ public function listAttributes(string $databaseId, string $collectionId, ?array * @param ?bool $xarray * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createBooleanColumn` instead. - * @see Tables::createBooleanColumn */ public function createBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): array { @@ -501,9 +480,6 @@ public function createBooleanAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateBooleanColumn` instead. - * @see Tables::updateBooleanColumn */ public function updateBooleanAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): array { @@ -546,9 +522,6 @@ public function updateBooleanAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createDatetimeColumn` instead. - * @see Tables::createDatetimeColumn */ public function createDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -595,9 +568,6 @@ public function createDatetimeAttribute(string $databaseId, string $collectionId * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateDatetimeColumn` instead. - * @see Tables::updateDatetimeColumn */ public function updateDatetimeAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -641,9 +611,6 @@ public function updateDatetimeAttribute(string $databaseId, string $collectionId * @param ?bool $xarray * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createEmailColumn` instead. - * @see Tables::createEmailColumn */ public function createEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -691,9 +658,6 @@ public function createEmailAttribute(string $databaseId, string $collectionId, s * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateEmailColumn` instead. - * @see Tables::updateEmailColumn */ public function updateEmailAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -726,8 +690,8 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s } /** - * Create an enum attribute. The `elements` param acts as a white-list of - * accepted values for this attribute. + * Create an enumeration attribute. The `elements` param acts as a white-list + * of accepted values for this attribute. * * * @param string $databaseId @@ -739,9 +703,6 @@ public function updateEmailAttribute(string $databaseId, string $collectionId, s * @param ?bool $xarray * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createEnumColumn` instead. - * @see Tables::createEnumColumn */ public function createEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -791,9 +752,6 @@ public function createEnumAttribute(string $databaseId, string $collectionId, st * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateEnumColumn` instead. - * @see Tables::updateEnumColumn */ public function updateEnumAttribute(string $databaseId, string $collectionId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -841,9 +799,6 @@ public function updateEnumAttribute(string $databaseId, string $collectionId, st * @param ?bool $xarray * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createFloatColumn` instead. - * @see Tables::createFloatColumn */ public function createFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): array { @@ -901,9 +856,6 @@ public function createFloatAttribute(string $databaseId, string $collectionId, s * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateFloatColumn` instead. - * @see Tables::updateFloatColumn */ public function updateFloatAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): array { @@ -958,9 +910,6 @@ public function updateFloatAttribute(string $databaseId, string $collectionId, s * @param ?bool $xarray * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createIntegerColumn` instead. - * @see Tables::createIntegerColumn */ public function createIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): array { @@ -1018,9 +967,6 @@ public function createIntegerAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateIntegerColumn` instead. - * @see Tables::updateIntegerColumn */ public function updateIntegerAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): array { @@ -1072,9 +1018,6 @@ public function updateIntegerAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createIpColumn` instead. - * @see Tables::createIpColumn */ public function createIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -1122,9 +1065,6 @@ public function createIpAttribute(string $databaseId, string $collectionId, stri * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateIpColumn` instead. - * @see Tables::updateIpColumn */ public function updateIpAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -1171,9 +1111,6 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri * @param ?RelationMutate $onDelete * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createRelationshipColumn` instead. - * @see Tables::createRelationshipColumn */ public function createRelationshipAttribute(string $databaseId, string $collectionId, string $relatedCollectionId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): array { @@ -1230,9 +1167,6 @@ public function createRelationshipAttribute(string $databaseId, string $collecti * @param ?bool $encrypt * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createStringColumn` instead. - * @see Tables::createStringColumn */ public function createStringAttribute(string $databaseId, string $collectionId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array { @@ -1286,9 +1220,6 @@ public function createStringAttribute(string $databaseId, string $collectionId, * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateStringColumn` instead. - * @see Tables::updateStringColumn */ public function updateStringAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array { @@ -1336,9 +1267,6 @@ public function updateStringAttribute(string $databaseId, string $collectionId, * @param ?bool $xarray * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createUrlColumn` instead. - * @see Tables::createUrlColumn */ public function createUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array { @@ -1386,9 +1314,6 @@ public function createUrlAttribute(string $databaseId, string $collectionId, str * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateUrlColumn` instead. - * @see Tables::updateUrlColumn */ public function updateUrlAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array { @@ -1428,9 +1353,6 @@ public function updateUrlAttribute(string $databaseId, string $collectionId, str * @param string $key * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `getColumn` instead. - * @see Tables::getColumn */ public function getAttribute(string $databaseId, string $collectionId, string $key): array { @@ -1463,9 +1385,6 @@ public function getAttribute(string $databaseId, string $collectionId, string $k * @param string $key * @throws AppwriteException * @return string - * - * @deprecated This API has been deprecated since 1.8.0. Please use `deleteColumn` instead. - * @see Tables::deleteColumn */ public function deleteAttribute(string $databaseId, string $collectionId, string $key): string { @@ -1503,9 +1422,6 @@ public function deleteAttribute(string $databaseId, string $collectionId, string * @param ?string $newKey * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateRelationshipColumn` instead. - * @see Tables::updateRelationshipColumn */ public function updateRelationshipAttribute(string $databaseId, string $collectionId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array { @@ -1548,9 +1464,6 @@ public function updateRelationshipAttribute(string $databaseId, string $collecti * @param ?array $queries * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `listRows` instead. - * @see Tables::listRows */ public function listDocuments(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -1591,9 +1504,6 @@ public function listDocuments(string $databaseId, string $collectionId, ?array $ * @param ?array $permissions * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createRow` instead. - * @see Tables::createRow */ public function createDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array { @@ -1639,9 +1549,6 @@ public function createDocument(string $databaseId, string $collectionId, string * @param array $documents * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createRow` instead. - * @see Tables::createRow */ public function createDocuments(string $databaseId, string $collectionId, array $documents): array { @@ -1680,13 +1587,11 @@ public function createDocuments(string $databaseId, string $collectionId, array * * @param string $databaseId * @param string $collectionId + * @param array $documents * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRows` instead. - * @see Tables::upsertRows */ - public function upsertDocuments(string $databaseId, string $collectionId): array + public function upsertDocuments(string $databaseId, string $collectionId, array $documents): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1697,6 +1602,7 @@ public function upsertDocuments(string $databaseId, string $collectionId): array $apiParams = []; $apiParams['databaseId'] = $databaseId; $apiParams['collectionId'] = $collectionId; + $apiParams['documents'] = $documents; $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1724,9 +1630,6 @@ public function upsertDocuments(string $databaseId, string $collectionId): array * @param ?array $queries * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateRows` instead. - * @see Tables::updateRows */ public function updateDocuments(string $databaseId, string $collectionId, ?array $data = null, ?array $queries = null): array { @@ -1772,9 +1675,6 @@ public function updateDocuments(string $databaseId, string $collectionId, ?array * @param ?array $queries * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `deleteRows` instead. - * @see Tables::deleteRows */ public function deleteDocuments(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -1813,9 +1713,6 @@ public function deleteDocuments(string $databaseId, string $collectionId, ?array * @param ?array $queries * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `getRow` instead. - * @see Tables::getRow */ public function getDocument(string $databaseId, string $collectionId, string $documentId, ?array $queries = null): array { @@ -1857,13 +1754,12 @@ public function getDocument(string $databaseId, string $collectionId, string $do * @param string $databaseId * @param string $collectionId * @param string $documentId + * @param array $data + * @param ?array $permissions * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `upsertRow` instead. - * @see Tables::upsertRow */ - public function upsertDocument(string $databaseId, string $collectionId, string $documentId): array + public function upsertDocument(string $databaseId, string $collectionId, string $documentId, array $data, ?array $permissions = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{documentId}'], @@ -1875,6 +1771,11 @@ public function upsertDocument(string $databaseId, string $collectionId, string $apiParams['databaseId'] = $databaseId; $apiParams['collectionId'] = $collectionId; $apiParams['documentId'] = $documentId; + $apiParams['data'] = $data; + + if (!is_null($permissions)) { + $apiParams['permissions'] = $permissions; + } $apiHeaders = []; $apiHeaders['content-type'] = 'application/json'; @@ -1898,9 +1799,6 @@ public function upsertDocument(string $databaseId, string $collectionId, string * @param ?array $permissions * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `updateRow` instead. - * @see Tables::updateRow */ public function updateDocument(string $databaseId, string $collectionId, string $documentId, ?array $data = null, ?array $permissions = null): array { @@ -1942,9 +1840,6 @@ public function updateDocument(string $databaseId, string $collectionId, string * @param string $documentId * @throws AppwriteException * @return string - * - * @deprecated This API has been deprecated since 1.8.0. Please use `deleteRow` instead. - * @see Tables::deleteRow */ public function deleteDocument(string $databaseId, string $collectionId, string $documentId): string { @@ -1981,9 +1876,6 @@ public function deleteDocument(string $databaseId, string $collectionId, string * @param ?float $min * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `decrementRowColumn` instead. - * @see Tables::decrementRowColumn */ public function decrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $min = null): array { @@ -2029,9 +1921,6 @@ public function decrementDocumentAttribute(string $databaseId, string $collectio * @param ?float $max * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `incrementRowColumn` instead. - * @see Tables::incrementRowColumn */ public function incrementDocumentAttribute(string $databaseId, string $collectionId, string $documentId, string $attribute, ?float $value = null, ?float $max = null): array { @@ -2074,9 +1963,6 @@ public function incrementDocumentAttribute(string $databaseId, string $collectio * @param ?array $queries * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `listIndexes` instead. - * @see Tables::listIndexes */ public function listIndexes(string $databaseId, string $collectionId, ?array $queries = null): array { @@ -2118,9 +2004,6 @@ public function listIndexes(string $databaseId, string $collectionId, ?array $qu * @param ?array $lengths * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `createIndex` instead. - * @see Tables::createIndex */ public function createIndex(string $databaseId, string $collectionId, string $key, IndexType $type, array $attributes, ?array $orders = null, ?array $lengths = null): array { @@ -2164,9 +2047,6 @@ public function createIndex(string $databaseId, string $collectionId, string $ke * @param string $key * @throws AppwriteException * @return array - * - * @deprecated This API has been deprecated since 1.8.0. Please use `getIndex` instead. - * @see Tables::getIndex */ public function getIndex(string $databaseId, string $collectionId, string $key): array { @@ -2199,9 +2079,6 @@ public function getIndex(string $databaseId, string $collectionId, string $key): * @param string $key * @throws AppwriteException * @return string - * - * @deprecated This API has been deprecated since 1.8.0. Please use `deleteIndex` instead. - * @see Tables::deleteIndex */ public function deleteIndex(string $databaseId, string $collectionId, string $key): string { diff --git a/src/Appwrite/Services/Tables.php b/src/Appwrite/Services/Tables.php deleted file mode 100644 index 88d9ffa..0000000 --- a/src/Appwrite/Services/Tables.php +++ /dev/null @@ -1,1906 +0,0 @@ -client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a new Table. Before using this route, you should create a new - * database resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param string $databaseId - * @param string $tableId - * @param string $name - * @param ?array $permissions - * @param ?bool $rowSecurity - * @param ?bool $enabled - * @throws AppwriteException - * @return array - */ - public function create(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array - { - $apiPath = str_replace( - ['{databaseId}'], - [$databaseId], - '/databases/{databaseId}/tables' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['name'] = $name; - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - if (!is_null($rowSecurity)) { - $apiParams['rowSecurity'] = $rowSecurity; - } - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a table by its unique ID. This endpoint response returns a JSON object - * with the table metadata. - * - * @param string $databaseId - * @param string $tableId - * @throws AppwriteException - * @return array - */ - public function get(string $databaseId, string $tableId): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a table by its unique ID. - * - * @param string $databaseId - * @param string $tableId - * @param string $name - * @param ?array $permissions - * @param ?bool $rowSecurity - * @param ?bool $enabled - * @throws AppwriteException - * @return array - */ - public function update(string $databaseId, string $tableId, string $name, ?array $permissions = null, ?bool $rowSecurity = null, ?bool $enabled = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['name'] = $name; - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - if (!is_null($rowSecurity)) { - $apiParams['rowSecurity'] = $rowSecurity; - } - - if (!is_null($enabled)) { - $apiParams['enabled'] = $enabled; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PUT, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete a table by its unique ID. Only users with write permissions have - * access to delete this resource. - * - * @param string $databaseId - * @param string $tableId - * @throws AppwriteException - * @return string - */ - public function delete(string $databaseId, string $tableId): string - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * List attributes in the collection. - * - * @param string $databaseId - * @param string $tableId - * @param ?array $queries - * @throws AppwriteException - * @return array - */ - public function listColumns(string $databaseId, string $tableId, ?array $queries = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a boolean column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?bool $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/boolean' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a boolean column. Changing the `default` value will not update - * already existing rows. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?bool $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateBooleanColumn(string $databaseId, string $tableId, string $key, bool $required, ?bool $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/boolean/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a date time column according to the ISO 8601 standard. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/datetime' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a date time column. Changing the `default` value will not update - * already existing rows. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateDatetimeColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/datetime/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create an email column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/email' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an email column. Changing the `default` value will not update - * already existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateEmailColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/email/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create an enumeration column. The `elements` param acts as a white-list of - * accepted values for this column. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param array $elements - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/enum' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['elements'] = $elements; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an enum column. Changing the `default` value will not update already - * existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param array $elements - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateEnumColumn(string $databaseId, string $tableId, string $key, array $elements, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/enum/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['elements'] = $elements; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a float column. Optionally, minimum and maximum values can be - * provided. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?float $min - * @param ?float $max - * @param ?float $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $min = null, ?float $max = null, ?float $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/float' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a float column. Changing the `default` value will not update already - * existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?float $xdefault - * @param ?float $min - * @param ?float $max - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateFloatColumn(string $databaseId, string $tableId, string $key, bool $required, ?float $xdefault, ?float $min = null, ?float $max = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/float/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create an integer column. Optionally, minimum and maximum values can be - * provided. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?int $min - * @param ?int $max - * @param ?int $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $min = null, ?int $max = null, ?int $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/integer' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an integer column. Changing the `default` value will not update - * already existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?int $xdefault - * @param ?int $min - * @param ?int $max - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateIntegerColumn(string $databaseId, string $tableId, string $key, bool $required, ?int $xdefault, ?int $min = null, ?int $max = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/integer/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create IP address column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/ip' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an ip column. Changing the `default` value will not update already - * existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateIpColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/ip/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * - * @param string $databaseId - * @param string $tableId - * @param string $relatedTableId - * @param RelationshipType $type - * @param ?bool $twoWay - * @param ?string $key - * @param ?string $twoWayKey - * @param ?RelationMutate $onDelete - * @throws AppwriteException - * @return array - */ - public function createRelationshipColumn(string $databaseId, string $tableId, string $relatedTableId, RelationshipType $type, ?bool $twoWay = null, ?string $key = null, ?string $twoWayKey = null, ?RelationMutate $onDelete = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/relationship' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['relatedTableId'] = $relatedTableId; - $apiParams['type'] = $type; - - if (!is_null($twoWay)) { - $apiParams['twoWay'] = $twoWay; - } - - if (!is_null($key)) { - $apiParams['key'] = $key; - } - - if (!is_null($twoWayKey)) { - $apiParams['twoWayKey'] = $twoWayKey; - } - - if (!is_null($onDelete)) { - $apiParams['onDelete'] = $onDelete; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a string column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param int $size - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @param ?bool $encrypt - * @throws AppwriteException - * @return array - */ - public function createStringColumn(string $databaseId, string $tableId, string $key, int $size, bool $required, ?string $xdefault = null, ?bool $xarray = null, ?bool $encrypt = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/string' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['size'] = $size; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - if (!is_null($encrypt)) { - $apiParams['encrypt'] = $encrypt; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a string column. Changing the `default` value will not update - * already existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?int $size - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateStringColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?int $size = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/string/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($size)) { - $apiParams['size'] = $size; - } - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a URL column. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?bool $xarray - * @throws AppwriteException - * @return array - */ - public function createUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?bool $xarray = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/columns/url' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - - if (!is_null($xdefault)) { - $apiParams['default'] = $xdefault; - } - - if (!is_null($xarray)) { - $apiParams['array'] = $xarray; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update an url column. Changing the `default` value will not update already - * existing rows. - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param bool $required - * @param ?string $xdefault - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateUrlColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/url/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['required'] = $required; - $apiParams['default'] = $xdefault; - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get column by ID. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @throws AppwriteException - * @return array - */ - public function getColumn(string $databaseId, string $tableId, string $key): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Deletes a column. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @throws AppwriteException - * @return string - */ - public function deleteColumn(string $databaseId, string $tableId, string $key): string - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update relationship column. [Learn more about relationship - * columns](https://appwrite.io/docs/databases-relationships#relationship-columns). - * - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param ?RelationMutate $onDelete - * @param ?string $newKey - * @throws AppwriteException - * @return array - */ - public function updateRelationshipColumn(string $databaseId, string $tableId, string $key, ?RelationMutate $onDelete = null, ?string $newKey = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/columns/{key}/relationship' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - if (!is_null($onDelete)) { - $apiParams['onDelete'] = $onDelete; - } - - if (!is_null($newKey)) { - $apiParams['newKey'] = $newKey; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * List indexes in the collection. - * - * @param string $databaseId - * @param string $tableId - * @param ?array $queries - * @throws AppwriteException - * @return array - */ - public function listIndexes(string $databaseId, string $tableId, ?array $queries = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/indexes' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Creates an index on the attributes listed. Your index should include all - * the attributes you will query in a single request. - * Attributes can be `key`, `fulltext`, and `unique`. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @param IndexType $type - * @param array $columns - * @param ?array $orders - * @param ?array $lengths - * @throws AppwriteException - * @return array - */ - public function createIndex(string $databaseId, string $tableId, string $key, IndexType $type, array $columns, ?array $orders = null, ?array $lengths = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/indexes' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - $apiParams['type'] = $type; - $apiParams['columns'] = $columns; - - if (!is_null($orders)) { - $apiParams['orders'] = $orders; - } - - if (!is_null($lengths)) { - $apiParams['lengths'] = $lengths; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get index by ID. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @throws AppwriteException - * @return array - */ - public function getIndex(string $databaseId, string $tableId, string $key): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/indexes/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete an index. - * - * @param string $databaseId - * @param string $tableId - * @param string $key - * @throws AppwriteException - * @return string - */ - public function deleteIndex(string $databaseId, string $tableId, string $key): string - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{key}'], - [$databaseId, $tableId, $key], - '/databases/{databaseId}/tables/{tableId}/indexes/{key}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['key'] = $key; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a list of all the user's rows in a given table. You can use the query - * params to filter your results. - * - * @param string $databaseId - * @param string $tableId - * @param ?array $queries - * @throws AppwriteException - * @return array - */ - public function listRows(string $databaseId, string $tableId, ?array $queries = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create a new Row. Before using this route, you should create a new table - * resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @param array $data - * @param ?array $permissions - * @throws AppwriteException - * @return array - */ - public function createRow(string $databaseId, string $tableId, string $rowId, array $data, ?array $permissions = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - $apiParams['data'] = $data; - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create new Rows. Before using this route, you should create a new table - * resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param string $databaseId - * @param string $tableId - * @param array $rows - * @throws AppwriteException - * @return array - */ - public function createRows(string $databaseId, string $tableId, array $rows): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rows'] = $rows; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_POST, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create or update Rows. Before using this route, you should create a new - * table resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * - * @param string $databaseId - * @param string $tableId - * @throws AppwriteException - * @return array - */ - public function upsertRows(string $databaseId, string $tableId): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PUT, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update all rows that match your queries, if no queries are submitted then - * all rows are updated. You can pass only specific fields to be updated. - * - * @param string $databaseId - * @param string $tableId - * @param ?array $data - * @param ?array $queries - * @throws AppwriteException - * @return array - */ - public function updateRows(string $databaseId, string $tableId, ?array $data = null, ?array $queries = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($data)) { - $apiParams['data'] = $data; - } - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Bulk delete rows using queries, if no queries are passed then all rows are - * deleted. - * - * @param string $databaseId - * @param string $tableId - * @param ?array $queries - * @throws AppwriteException - * @return array - */ - public function deleteRows(string $databaseId, string $tableId, ?array $queries = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}'], - [$databaseId, $tableId], - '/databases/{databaseId}/tables/{tableId}/rows' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Get a row by its unique ID. This endpoint response returns a JSON object - * with the row data. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @param ?array $queries - * @throws AppwriteException - * @return array - */ - public function getRow(string $databaseId, string $tableId, string $rowId, ?array $queries = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}'], - [$databaseId, $tableId, $rowId], - '/databases/{databaseId}/tables/{tableId}/rows/{rowId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - - if (!is_null($queries)) { - $apiParams['queries'] = $queries; - } - - $apiHeaders = []; - - return $this->client->call( - Client::METHOD_GET, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Create or update a Row. Before using this route, you should create a new - * table resource using either a [server - * integration](https://appwrite.io/docs/server/databases#databasesCreateTable) - * API or directly from your database console. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @throws AppwriteException - * @return array - */ - public function upsertRow(string $databaseId, string $tableId, string $rowId): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}'], - [$databaseId, $tableId, $rowId], - '/databases/{databaseId}/tables/{tableId}/rows/{rowId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PUT, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Update a row by its unique ID. Using the patch method you can pass only - * specific fields that will get updated. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @param ?array $data - * @param ?array $permissions - * @throws AppwriteException - * @return array - */ - public function updateRow(string $databaseId, string $tableId, string $rowId, ?array $data = null, ?array $permissions = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}'], - [$databaseId, $tableId, $rowId], - '/databases/{databaseId}/tables/{tableId}/rows/{rowId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - - if (!is_null($data)) { - $apiParams['data'] = $data; - } - - if (!is_null($permissions)) { - $apiParams['permissions'] = $permissions; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Delete a row by its unique ID. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @throws AppwriteException - * @return string - */ - public function deleteRow(string $databaseId, string $tableId, string $rowId): string - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}'], - [$databaseId, $tableId, $rowId], - '/databases/{databaseId}/tables/{tableId}/rows/{rowId}' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_DELETE, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Decrement a specific column of a row by a given value. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @param string $column - * @param ?float $value - * @param ?float $min - * @throws AppwriteException - * @return array - */ - public function decrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $min = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}', '{column}'], - [$databaseId, $tableId, $rowId, $column], - '/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - $apiParams['column'] = $column; - - if (!is_null($value)) { - $apiParams['value'] = $value; - } - - if (!is_null($min)) { - $apiParams['min'] = $min; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } - - /** - * Increment a specific column of a row by a given value. - * - * @param string $databaseId - * @param string $tableId - * @param string $rowId - * @param string $column - * @param ?float $value - * @param ?float $max - * @throws AppwriteException - * @return array - */ - public function incrementRowColumn(string $databaseId, string $tableId, string $rowId, string $column, ?float $value = null, ?float $max = null): array - { - $apiPath = str_replace( - ['{databaseId}', '{tableId}', '{rowId}', '{column}'], - [$databaseId, $tableId, $rowId, $column], - '/databases/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment' - ); - - $apiParams = []; - $apiParams['databaseId'] = $databaseId; - $apiParams['tableId'] = $tableId; - $apiParams['rowId'] = $rowId; - $apiParams['column'] = $column; - - if (!is_null($value)) { - $apiParams['value'] = $value; - } - - if (!is_null($max)) { - $apiParams['max'] = $max; - } - - $apiHeaders = []; - $apiHeaders['content-type'] = 'application/json'; - - return $this->client->call( - Client::METHOD_PATCH, - $apiPath, - $apiHeaders, - $apiParams - ); - } -} \ No newline at end of file diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index ef429e9..e870542 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -922,7 +922,8 @@ public function testMethodUpsertDocuments(): void { $response = $this->databases->upsertDocuments( "", - "" + "", + array() ); $this->assertSame($data, $response); @@ -1010,7 +1011,8 @@ public function testMethodUpsertDocument(): void { $response = $this->databases->upsertDocument( "", "", - "" + "", + array() ); $this->assertSame($data, $response); diff --git a/tests/Appwrite/Services/TablesTest.php b/tests/Appwrite/Services/TablesTest.php deleted file mode 100644 index 92ab33b..0000000 --- a/tests/Appwrite/Services/TablesTest.php +++ /dev/null @@ -1,1107 +0,0 @@ -client = Mockery::mock(Client::class); - $this->tables = new Tables($this->client); - } - - public function testMethodList(): void { - - $data = array( - "total" => 5, - "tables" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->list( - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreate(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(), - "databaseId" => "5e5ea5c16897e", - "name" => "My Table", - "enabled" => true, - "rowSecurity" => true, - "columns" => array(), - "indexes" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->create( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodGet(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(), - "databaseId" => "5e5ea5c16897e", - "name" => "My Table", - "enabled" => true, - "rowSecurity" => true, - "columns" => array(), - "indexes" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->get( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdate(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(), - "databaseId" => "5e5ea5c16897e", - "name" => "My Table", - "enabled" => true, - "rowSecurity" => true, - "columns" => array(), - "indexes" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->update( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDelete(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->delete( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodListColumns(): void { - - $data = array( - "total" => 5, - "columns" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->listColumns( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateBooleanColumn(): void { - - $data = array( - "key" => "isEnabled", - "type" => "boolean", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createBooleanColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateBooleanColumn(): void { - - $data = array( - "key" => "isEnabled", - "type" => "boolean", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateBooleanColumn( - "", - "", - "", - true, - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateDatetimeColumn(): void { - - $data = array( - "key" => "birthDay", - "type" => "datetime", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "datetime",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createDatetimeColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateDatetimeColumn(): void { - - $data = array( - "key" => "birthDay", - "type" => "datetime", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "datetime",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateDatetimeColumn( - "", - "", - "", - true, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateEmailColumn(): void { - - $data = array( - "key" => "userEmail", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "email",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createEmailColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateEmailColumn(): void { - - $data = array( - "key" => "userEmail", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "email",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateEmailColumn( - "", - "", - "", - true, - "email@example.com" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateEnumColumn(): void { - - $data = array( - "key" => "status", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "elements" => array(), - "format" => "enum",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createEnumColumn( - "", - "", - "", - array(), - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateEnumColumn(): void { - - $data = array( - "key" => "status", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "elements" => array(), - "format" => "enum",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateEnumColumn( - "", - "", - "", - array(), - true, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateFloatColumn(): void { - - $data = array( - "key" => "percentageCompleted", - "type" => "double", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createFloatColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateFloatColumn(): void { - - $data = array( - "key" => "percentageCompleted", - "type" => "double", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateFloatColumn( - "", - "", - "", - true, - 1.0 - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateIntegerColumn(): void { - - $data = array( - "key" => "count", - "type" => "integer", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createIntegerColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateIntegerColumn(): void { - - $data = array( - "key" => "count", - "type" => "integer", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateIntegerColumn( - "", - "", - "", - true, - 1 - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateIpColumn(): void { - - $data = array( - "key" => "ipAddress", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "ip",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createIpColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateIpColumn(): void { - - $data = array( - "key" => "ipAddress", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "ip",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateIpColumn( - "", - "", - "", - true, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateRelationshipColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "relatedTable" => "table", - "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", - "twoWay" => true, - "twoWayKey" => "string", - "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createRelationshipColumn( - "", - "", - "", - "oneToOne" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateStringColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "size" => 128,); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createStringColumn( - "", - "", - "", - 1, - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateStringColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "size" => 128,); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateStringColumn( - "", - "", - "", - true, - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateUrlColumn(): void { - - $data = array( - "key" => "githubUrl", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "url",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createUrlColumn( - "", - "", - "", - true - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateUrlColumn(): void { - - $data = array( - "key" => "githubUrl", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "format" => "url",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateUrlColumn( - "", - "", - "", - true, - "https://example.com" - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetColumn(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->getColumn( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteColumn(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->deleteColumn( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateRelationshipColumn(): void { - - $data = array( - "key" => "fullName", - "type" => "string", - "status" => "available", - "error" => "string", - "required" => true, - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "relatedTable" => "table", - "relationType" => "oneToOne|oneToMany|manyToOne|manyToMany", - "twoWay" => true, - "twoWayKey" => "string", - "onDelete" => "restrict|cascade|setNull", - "side" => "parent|child",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateRelationshipColumn( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodListIndexes(): void { - - $data = array( - "total" => 5, - "indexes" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->listIndexes( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateIndex(): void { - - $data = array( - "key" => "index1", - "type" => "primary", - "status" => "available", - "error" => "string", - "columns" => array(), - "lengths" => array(), - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createIndex( - "", - "", - "", - "key", - array() - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetIndex(): void { - - $data = array( - "key" => "index1", - "type" => "primary", - "status" => "available", - "error" => "string", - "columns" => array(), - "lengths" => array(), - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00",); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->getIndex( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteIndex(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->deleteIndex( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodListRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->listRows( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateRow(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "5e5ea5c15117e", - "\$databaseId" => "5e5ea5c15117e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createRow( - "", - "", - "", - array() - ); - - $this->assertSame($data, $response); - } - - public function testMethodCreateRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->createRows( - "", - "", - array() - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpsertRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->upsertRows( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateRows( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteRows(): void { - - $data = array( - "total" => 5, - "rows" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->deleteRows( - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodGetRow(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "5e5ea5c15117e", - "\$databaseId" => "5e5ea5c15117e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->getRow( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpsertRow(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "5e5ea5c15117e", - "\$databaseId" => "5e5ea5c15117e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->upsertRow( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodUpdateRow(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "5e5ea5c15117e", - "\$databaseId" => "5e5ea5c15117e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->updateRow( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDeleteRow(): void { - - $data = ''; - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->deleteRow( - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodDecrementRowColumn(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "5e5ea5c15117e", - "\$databaseId" => "5e5ea5c15117e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->decrementRowColumn( - "", - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - - public function testMethodIncrementRowColumn(): void { - - $data = array( - "\$id" => "5e5ea5c16897e", - "\$sequence" => 1, - "\$tableId" => "5e5ea5c15117e", - "\$databaseId" => "5e5ea5c15117e", - "\$createdAt" => "2020-10-15T06:38:00.000+00:00", - "\$updatedAt" => "2020-10-15T06:38:00.000+00:00", - "\$permissions" => array(),); - - - $this->client - ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) - ->andReturn($data); - - $response = $this->tables->incrementRowColumn( - "", - "", - "", - "" - ); - - $this->assertSame($data, $response); - } - -} From 5bdd2a76aa67777ff10f59f22bca92bda5e802df Mon Sep 17 00:00:00 2001 From: root Date: Fri, 1 Aug 2025 03:34:58 +0000 Subject: [PATCH 4/4] chore: add changelog --- CHANGELOG.md | 10 +++++++++- src/Appwrite/Client.php | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4d35e..d5a323c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1 +1,9 @@ -# Change Log \ No newline at end of file +# Change Log + +## 15.1.0 + +* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service +* Add `dart38` and `flutter332` support to runtime models +* Add `gif` support to `ImageFormat` enum +* Add `upsertDocument` support to `Databases` service +* Add `sequence` support to `Document` model diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 27f8cca..4288210 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -37,11 +37,11 @@ class Client */ protected array $headers = [ 'content-type' => '', - 'user-agent' => 'AppwritePHPSDK/15.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/15.1.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '15.0.0', + 'x-sdk-version'=> '15.1.0', ]; /**