From eb6dc3d594ac962c790623b0adcdb3bbf5f672c6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 01:30:32 +1200 Subject: [PATCH 1/6] Add time between queries --- docs/avatars.md | 2 +- docs/databases.md | 105 +++++++ .../databases/create-line-attribute.md | 19 ++ .../databases/create-point-attribute.md | 19 ++ .../databases/create-polygon-attribute.md | 19 ++ .../databases/update-line-attribute.md | 20 ++ .../databases/update-point-attribute.md | 20 ++ .../databases/update-polygon-attribute.md | 20 ++ docs/examples/tablesdb/create-line-column.md | 19 ++ docs/examples/tablesdb/create-point-column.md | 19 ++ .../tablesdb/create-polygon-column.md | 19 ++ docs/examples/tablesdb/update-line-column.md | 20 ++ docs/examples/tablesdb/update-point-column.md | 20 ++ .../tablesdb/update-polygon-column.md | 20 ++ docs/functions.md | 2 +- docs/tablesdb.md | 105 +++++++ src/Appwrite/Client.php | 4 +- src/Appwrite/Enums/CreditCard.php | 10 +- src/Appwrite/Enums/ExecutionMethod.php | 8 + src/Appwrite/Enums/IndexType.php | 8 + src/Appwrite/Query.php | 24 ++ src/Appwrite/Services/Account.php | 6 +- src/Appwrite/Services/Databases.php | 262 +++++++++++++++++- src/Appwrite/Services/TablesDb.php | 240 ++++++++++++++++ tests/Appwrite/QueryTest.php | 8 + tests/Appwrite/Services/DatabasesTest.php | 156 +++++++++++ tests/Appwrite/Services/TablesDbTest.php | 156 +++++++++++ 27 files changed, 1317 insertions(+), 13 deletions(-) create mode 100644 docs/examples/databases/create-line-attribute.md create mode 100644 docs/examples/databases/create-point-attribute.md create mode 100644 docs/examples/databases/create-polygon-attribute.md create mode 100644 docs/examples/databases/update-line-attribute.md create mode 100644 docs/examples/databases/update-point-attribute.md create mode 100644 docs/examples/databases/update-polygon-attribute.md create mode 100644 docs/examples/tablesdb/create-line-column.md create mode 100644 docs/examples/tablesdb/create-point-column.md create mode 100644 docs/examples/tablesdb/create-polygon-column.md create mode 100644 docs/examples/tablesdb/update-line-column.md create mode 100644 docs/examples/tablesdb/update-point-column.md create mode 100644 docs/examples/tablesdb/update-polygon-column.md diff --git a/docs/avatars.md b/docs/avatars.md index 97bbfc3..1517dc7 100644 --- a/docs/avatars.md +++ b/docs/avatars.md @@ -32,7 +32,7 @@ When one dimension is specified and the other is 0, the image is scaled with pre | Field Name | Type | Description | Default | | --- | --- | --- | --- | -| code | string | **Required** Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro, rupay. | | +| code | string | **Required** Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, unionpay, visa, mir, maestro, rupay. | | | width | integer | Image width. Pass an integer between 0 to 2000. Defaults to 100. | 100 | | height | integer | Image height. Pass an integer between 0 to 2000. Defaults to 100. | 100 | | quality | integer | Image quality. Pass an integer between 0 to 100. Defaults to keep existing image quality. | -1 | diff --git a/docs/databases.md b/docs/databases.md index 998532a..e96ad7c 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -439,6 +439,111 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | newKey | string | New Attribute Key. | | +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/line +``` + +** Create a geometric line attribute. ** + +### Parameters + +| 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). | | +| key | string | Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/line/{key} +``` + +** Update a line attribute. Changing the `default` value will not update already existing documents. ** + +### Parameters + +| 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). | | +| key | string | **Required** Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | +| newKey | string | New attribute key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/point +``` + +** Create a geometric 2d point attribute. ** + +### Parameters + +| 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). | | +| key | string | Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/point/{key} +``` + +** Update a point attribute. Changing the `default` value will not update already existing documents. ** + +### Parameters + +| 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). | | +| key | string | **Required** Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | +| newKey | string | New attribute key. | | + + +```http request +POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/polygon +``` + +** Create a geometric polygon attribute. ** + +### Parameters + +| 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). | | +| key | string | Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key} +``` + +** Update a polygon attribute. Changing the `default` value will not update already existing documents. ** + +### Parameters + +| 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). | | +| key | string | **Required** Attribute Key. | | +| required | boolean | Is attribute required? | | +| default | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | +| newKey | string | New attribute key. | | + + ```http request POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/relationship ``` diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md new file mode 100644 index 0000000..5d4f968 --- /dev/null +++ b/docs/examples/databases/create-line-attribute.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createLineAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md new file mode 100644 index 0000000..1c8cdb5 --- /dev/null +++ b/docs/examples/databases/create-point-attribute.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createPointAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md new file mode 100644 index 0000000..0608d33 --- /dev/null +++ b/docs/examples/databases/create-polygon-attribute.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$databases = new Databases($client); + +$result = $databases->createPolygonAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md new file mode 100644 index 0000000..a5de545 --- /dev/null +++ b/docs/examples/databases/update-line-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->updateLineAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md new file mode 100644 index 0000000..0499663 --- /dev/null +++ b/docs/examples/databases/update-point-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->updatePointAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md new file mode 100644 index 0000000..99c63f1 --- /dev/null +++ b/docs/examples/databases/update-polygon-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->updatePolygonAttribute( + databaseId: '', + collectionId: '', + key: '', + required: false, + default: '', // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md new file mode 100644 index 0000000..daab57e --- /dev/null +++ b/docs/examples/tablesdb/create-line-column.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createLineColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md new file mode 100644 index 0000000..6b8cf1d --- /dev/null +++ b/docs/examples/tablesdb/create-point-column.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createPointColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md new file mode 100644 index 0000000..1114746 --- /dev/null +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -0,0 +1,19 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->createPolygonColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md new file mode 100644 index 0000000..ac2584d --- /dev/null +++ b/docs/examples/tablesdb/update-line-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updateLineColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md new file mode 100644 index 0000000..159f893 --- /dev/null +++ b/docs/examples/tablesdb/update-point-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updatePointColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md new file mode 100644 index 0000000..3f6f3e8 --- /dev/null +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -0,0 +1,20 @@ +setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint + ->setProject('') // Your project ID + ->setKey(''); // Your secret API key + +$tablesDB = new TablesDB($client); + +$result = $tablesDB->updatePolygonColumn( + databaseId: '', + tableId: '', + key: '', + required: false, + default: '', // optional + newKey: '' // optional +); \ No newline at end of file diff --git a/docs/functions.md b/docs/functions.md index 4e55bba..ff64822 100644 --- a/docs/functions.md +++ b/docs/functions.md @@ -303,7 +303,7 @@ POST https://cloud.appwrite.io/v1/functions/{functionId}/executions | body | string | HTTP body of execution. Default value is empty string. | | | async | boolean | Execute code in the background. Default value is false. | | | path | string | HTTP path of execution. Path can include query params. Default value is / | / | -| method | string | HTTP method of execution. Default value is GET. | POST | +| method | string | HTTP method of execution. Default value is POST. | POST | | headers | object | HTTP headers of execution. Defaults to empty. | {} | | scheduledAt | string | Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes. | | diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 4e37b4a..904424b 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -438,6 +438,111 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | newKey | string | New Column Key. | | +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/line +``` + +** Create a geometric line attribute. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key} +``` + +** Update a line column. Changing the `default` value will not update already existing documents. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/point +``` + +** Create a geometric point attribute. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key} +``` + +** Update a point column. Changing the `default` value will not update already existing documents. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + +```http request +POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/polygon +``` + +** Create a geometric polygon attribute. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | + + +```http request +PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key} +``` + +** Update a polygon column. Changing the `default` value will not update already existing documents. ** + +### Parameters + +| Field Name | Type | Description | Default | +| --- | --- | --- | --- | +| databaseId | string | **Required** Database ID. | | +| tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | +| key | string | **Required** Column Key. | | +| required | boolean | Is column required? | | +| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| newKey | string | New Column Key. | | + + ```http request POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/relationship ``` diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 5c1c208..9410c69 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/16.1.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '16.0.0', + 'x-sdk-version'=> '16.1.0', ]; /** diff --git a/src/Appwrite/Enums/CreditCard.php b/src/Appwrite/Enums/CreditCard.php index d79834e..416a5b4 100644 --- a/src/Appwrite/Enums/CreditCard.php +++ b/src/Appwrite/Enums/CreditCard.php @@ -18,7 +18,7 @@ class CreditCard implements JsonSerializable private static CreditCard $MASTERCARD; private static CreditCard $NARANJA; private static CreditCard $TARJETASHOPPING; - private static CreditCard $UNIONCHINAPAY; + private static CreditCard $UNIONPAY; private static CreditCard $VISA; private static CreditCard $MIR; private static CreditCard $MAESTRO; @@ -125,12 +125,12 @@ public static function TARJETASHOPPING(): CreditCard } return self::$TARJETASHOPPING; } - public static function UNIONCHINAPAY(): CreditCard + public static function UNIONPAY(): CreditCard { - if (!isset(self::$UNIONCHINAPAY)) { - self::$UNIONCHINAPAY = new CreditCard('union-china-pay'); + if (!isset(self::$UNIONPAY)) { + self::$UNIONPAY = new CreditCard('unionpay'); } - return self::$UNIONCHINAPAY; + return self::$UNIONPAY; } public static function VISA(): CreditCard { diff --git a/src/Appwrite/Enums/ExecutionMethod.php b/src/Appwrite/Enums/ExecutionMethod.php index 9ffea9c..6f16869 100644 --- a/src/Appwrite/Enums/ExecutionMethod.php +++ b/src/Appwrite/Enums/ExecutionMethod.php @@ -12,6 +12,7 @@ class ExecutionMethod implements JsonSerializable private static ExecutionMethod $PATCH; private static ExecutionMethod $DELETE; private static ExecutionMethod $OPTIONS; + private static ExecutionMethod $HEAD; private string $value; @@ -72,4 +73,11 @@ public static function OPTIONS(): ExecutionMethod } return self::$OPTIONS; } + public static function HEAD(): ExecutionMethod + { + if (!isset(self::$HEAD)) { + self::$HEAD = new ExecutionMethod('HEAD'); + } + return self::$HEAD; + } } \ No newline at end of file diff --git a/src/Appwrite/Enums/IndexType.php b/src/Appwrite/Enums/IndexType.php index fa71d60..16d0433 100644 --- a/src/Appwrite/Enums/IndexType.php +++ b/src/Appwrite/Enums/IndexType.php @@ -9,6 +9,7 @@ class IndexType implements JsonSerializable private static IndexType $KEY; private static IndexType $FULLTEXT; private static IndexType $UNIQUE; + private static IndexType $SPATIAL; private string $value; @@ -48,4 +49,11 @@ public static function UNIQUE(): IndexType } return self::$UNIQUE; } + public static function SPATIAL(): IndexType + { + if (!isset(self::$SPATIAL)) { + self::$SPATIAL = new IndexType('spatial'); + } + return self::$SPATIAL; + } } \ No newline at end of file diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index ab717fd..68c28c2 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -350,6 +350,18 @@ public static function createdAfter(string $value): string return (new Query('createdAfter', null, $value))->__toString(); } + /** + * Created Between + * + * @param string $start + * @param string $end + * @return string + */ + public static function createdBetween(string $start, string $end): string + { + return (new Query('createdBetween', null, [$start, $end]))->__toString(); + } + /** * Updated Before * @@ -372,6 +384,18 @@ public static function updatedAfter(string $value): string return (new Query('updatedAfter', null, $value))->__toString(); } + /** + * Updated Between + * + * @param string $start + * @param string $end + * @return string + */ + public static function updatedBetween(string $start, string $end): string + { + return (new Query('updatedBetween', null, [$start, $end]))->__toString(); + } + /** * Or * diff --git a/src/Appwrite/Services/Account.php b/src/Appwrite/Services/Account.php index ca28ff4..76b8bd5 100644 --- a/src/Appwrite/Services/Account.php +++ b/src/Appwrite/Services/Account.php @@ -1227,7 +1227,8 @@ public function createEmailPasswordSession(string $email, string $password): arr * @throws AppwriteException * @return array * - * @deprecated This API has been deprecated. + * @deprecated This API has been deprecated since 1.6.0. Please use `createSession` instead. + * @see Account::createSession */ public function updateMagicURLSession(string $userId, string $secret): array { @@ -1262,7 +1263,8 @@ public function updateMagicURLSession(string $userId, string $secret): array * @throws AppwriteException * @return array * - * @deprecated This API has been deprecated. + * @deprecated This API has been deprecated since 1.6.0. Please use `createSession` instead. + * @see Account::createSession */ public function updatePhoneSession(string $userId, string $secret): array { diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 1060a0a..64592ac 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -67,8 +67,8 @@ public function list(?array $queries = null, ?string $search = null): array * @throws AppwriteException * @return array * - * @deprecated This API has been deprecated since 1.8.0. Please use `createDatabase` instead. - * @see TablesDB::createDatabase + * @deprecated This API has been deprecated since 1.8.0. Please use `create` instead. + * @see TablesDB::create */ public function create(string $databaseId, string $name, ?bool $enabled = null): array { @@ -1171,6 +1171,264 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri ); } + /** + * Create a geometric line attribute. + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createLineColumn` instead. + * @see TablesDB::createLineColumn + */ + public function createLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}'], + [$databaseId, $collectionId], + '/databases/{databaseId}/collections/{collectionId}/attributes/line' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a line attribute. Changing the `default` value will not update + * already existing documents. + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updateLineColumn` instead. + * @see TablesDB::updateLineColumn + */ + public function updateLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{key}'], + [$databaseId, $collectionId, $key], + '/databases/{databaseId}/collections/{collectionId}/attributes/line/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $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 geometric 2d point attribute. + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createPointColumn` instead. + * @see TablesDB::createPointColumn + */ + public function createPointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}'], + [$databaseId, $collectionId], + '/databases/{databaseId}/collections/{collectionId}/attributes/point' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a point attribute. Changing the `default` value will not update + * already existing documents. + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updatePointColumn` instead. + * @see TablesDB::updatePointColumn + */ + public function updatePointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{key}'], + [$databaseId, $collectionId, $key], + '/databases/{databaseId}/collections/{collectionId}/attributes/point/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $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 geometric polygon attribute. + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `createPolygonColumn` instead. + * @see TablesDB::createPolygonColumn + */ + public function createPolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}'], + [$databaseId, $collectionId], + '/databases/{databaseId}/collections/{collectionId}/attributes/polygon' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a polygon attribute. Changing the `default` value will not update + * already existing documents. + * + * @param string $databaseId + * @param string $collectionId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + * + * @deprecated This API has been deprecated since 1.8.0. Please use `updatePolygonColumn` instead. + * @see TablesDB::updatePolygonColumn + */ + public function updatePolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{collectionId}', '{key}'], + [$databaseId, $collectionId, $key], + '/databases/{databaseId}/collections/{collectionId}/attributes/polygon/{key}' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['collectionId'] = $collectionId; + $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 attribute. [Learn more about relationship * attributes](https://appwrite.io/docs/databases-relationships#relationship-attributes). diff --git a/src/Appwrite/Services/TablesDb.php b/src/Appwrite/Services/TablesDb.php index 59a4254..7430ad7 100644 --- a/src/Appwrite/Services/TablesDb.php +++ b/src/Appwrite/Services/TablesDb.php @@ -1095,6 +1095,246 @@ public function updateIpColumn(string $databaseId, string $tableId, string $key, ); } + /** + * Create a geometric line attribute. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @throws AppwriteException + * @return array + */ + public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/line' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a line column. Changing the `default` value will not update already + * existing documents. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/line/{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 geometric point attribute. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @throws AppwriteException + * @return array + */ + public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/point' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a point column. Changing the `default` value will not update already + * existing documents. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/point/{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 geometric polygon attribute. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @throws AppwriteException + * @return array + */ + public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}'], + [$databaseId, $tableId], + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon' + ); + + $apiParams = []; + $apiParams['databaseId'] = $databaseId; + $apiParams['tableId'] = $tableId; + $apiParams['key'] = $key; + $apiParams['required'] = $required; + $apiParams['default'] = $xdefault; + + $apiHeaders = []; + $apiHeaders['content-type'] = 'application/json'; + + return $this->client->call( + Client::METHOD_POST, + $apiPath, + $apiHeaders, + $apiParams + ); + } + + /** + * Update a polygon column. Changing the `default` value will not update + * already existing documents. + * + * @param string $databaseId + * @param string $tableId + * @param string $key + * @param bool $required + * @param ?string $xdefault + * @param ?string $newKey + * @throws AppwriteException + * @return array + */ + public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + { + $apiPath = str_replace( + ['{databaseId}', '{tableId}', '{key}'], + [$databaseId, $tableId, $key], + '/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{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). diff --git a/tests/Appwrite/QueryTest.php b/tests/Appwrite/QueryTest.php index a9ac2c3..01332ef 100644 --- a/tests/Appwrite/QueryTest.php +++ b/tests/Appwrite/QueryTest.php @@ -183,6 +183,10 @@ public function testCreatedAfter(): void { $this->assertSame('createdAfter("2023-01-01")', Query::createdAfter('2023-01-01')); } + public function testCreatedBetween(): void { + $this->assertSame('{"method":"createdBetween","values":["2023-01-01","2023-12-31"]}', Query::createdBetween('2023-01-01', '2023-12-31')); + } + public function testUpdatedBefore(): void { $this->assertSame('updatedBefore("2023-01-01")', Query::updatedBefore('2023-01-01')); } @@ -190,4 +194,8 @@ public function testUpdatedBefore(): void { public function testUpdatedAfter(): void { $this->assertSame('updatedAfter("2023-01-01")', Query::updatedAfter('2023-01-01')); } + + public function testUpdatedBetween(): void { + $this->assertSame('{"method":"updatedBetween","values":["2023-01-01","2023-12-31"]}', Query::updatedBetween('2023-01-01', '2023-12-31')); + } } diff --git a/tests/Appwrite/Services/DatabasesTest.php b/tests/Appwrite/Services/DatabasesTest.php index b11271f..daa113b 100644 --- a/tests/Appwrite/Services/DatabasesTest.php +++ b/tests/Appwrite/Services/DatabasesTest.php @@ -637,6 +637,162 @@ public function testMethodUpdateIpAttribute(): void { $this->assertSame($data, $response); } + public function testMethodCreateLineAttribute(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createLineAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateLineAttribute(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updateLineAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePointAttribute(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createPointAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePointAttribute(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updatePointAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePolygonAttribute(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->createPolygonAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePolygonAttribute(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->databases->updatePolygonAttribute( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateRelationshipAttribute(): void { $data = array( diff --git a/tests/Appwrite/Services/TablesDbTest.php b/tests/Appwrite/Services/TablesDbTest.php index 6a47bea..34c01d1 100644 --- a/tests/Appwrite/Services/TablesDbTest.php +++ b/tests/Appwrite/Services/TablesDbTest.php @@ -637,6 +637,162 @@ public function testMethodUpdateIpColumn(): void { $this->assertSame($data, $response); } + public function testMethodCreateLineColumn(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createLineColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdateLineColumn(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updateLineColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePointColumn(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createPointColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePointColumn(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updatePointColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodCreatePolygonColumn(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->createPolygonColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + + public function testMethodUpdatePolygonColumn(): 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",); + + + $this->client + ->allows()->call(Mockery::any(), Mockery::any(), Mockery::any(), Mockery::any()) + ->andReturn($data); + + $response = $this->tablesDB->updatePolygonColumn( + "", + "", + "", + true + ); + + $this->assertSame($data, $response); + } + public function testMethodCreateRelationshipColumn(): void { $data = array( From 59f63988598b4d6bbd01111d63bde6122f8c4b16 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 02:14:36 +1200 Subject: [PATCH 2/6] Update version --- src/Appwrite/Client.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 9410c69..e36b38e 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.1.0 ()', + 'user-agent' => 'AppwritePHPSDK/17.0.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '16.1.0', + 'x-sdk-version'=> '17.0.0', ]; /** From 2494c381bd7266217a6e07d6028a394fab3318d2 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 21:41:05 +1200 Subject: [PATCH 3/6] Add spatial queries --- src/Appwrite/Client.php | 2 +- src/Appwrite/Query.php | 149 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index e36b38e..49aa1ae 100644 --- a/src/Appwrite/Client.php +++ b/src/Appwrite/Client.php @@ -262,7 +262,7 @@ public function call( $warnings = $responseHeaders['x-appwrite-warning'] ?? ''; if ($warnings) { foreach(explode(';', $warnings) as $warning) { - echo 'Warning: ' . $warning . PHP_EOL; + \trigger_error($warning, E_USER_WARNING); } } diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index 68c28c2..c714c82 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -423,4 +423,153 @@ public static function and(array $queries): string } return (new Query('and', null, $queries))->__toString(); } + + /** + * Distance Equal + * + * @param string $attribute + * @param array $values + * @param int|float $distance + * @return string + */ + public static function distanceEqual(string $attribute, array $values, int|float $distance, bool $meters = true): string + { + return (new Query('distanceEqual', $attribute, [$values, $distance, $meters]))->__toString(); + } + + /** + * Distance Not Equal + * + * @param string $attribute + * @param array $values + * @param int|float $distance + * @return string + */ + public static function distanceNotEqual(string $attribute, array $values, int|float $distance, bool $meters = true): string + { + return (new Query('distanceNotEqual', $attribute, [$values, $distance, $meters]))->__toString(); + } + + /** + * Distance Greater Than + * + * @param string $attribute + * @param array $values + * @param int|float $distance + * @return string + */ + public static function distanceGreaterThan(string $attribute, array $values, int|float $distance, bool $meters = true): string + { + return (new Query('distanceGreaterThan', $attribute, [$values, $distance, $meters]))->__toString(); + } + + /** + * Distance Less Than + * + * @param string $attribute + * @param array $values + * @param int|float $distance + * @param bool $meters + * @return string + */ + public static function distanceLessThan(string $attribute, array $values, int|float $distance, bool $meters = true): string + { + return (new Query('distanceLessThan', $attribute, [$values, $distance, $meters]))->__toString(); + } + + /** + * Intersects + * + * @param string $attribute + * @param array $values + * @return string + */ + public static function intersects(string $attribute, array $values): string + { + return (new Query('intersects', $attribute, $values))->__toString(); + } + + /** + * Not Intersects + * + * @param string $attribute + * @param array $values + * @return string + */ + public static function notIntersects(string $attribute, array $values): string + { + return (new Query('notIntersects', $attribute, $values))->__toString(); + } + + /** + * Crosses + * + * @param string $attribute + * @param array $values + * @return string + */ + public static function crosses(string $attribute, array $values): string + { + return (new Query('crosses', $attribute, $values))->__toString(); + } + + /** + * Not Crosses + * + * @param string $attribute + * @param array $values + * @return string + */ + public static function notCrosses(string $attribute, array $values): string + { + return (new Query('notCrosses', $attribute, $values))->__toString(); + } + + /** + * Overlaps + * + * @param string $attribute + * @param array $values + * @return string + */ + public static function overlaps(string $attribute, array $values): string + { + return (new Query('overlaps', $attribute, $values))->__toString(); + } + + /** + * Not Overlaps + * + * @param string $attribute + * @param array $values + * @return string + */ + public static function notOverlaps(string $attribute, array $values): string + { + return (new Query('notOverlaps', $attribute, $values))->__toString(); + } + + /** + * Touches + * + * @param string $attribute + * @param array $values + * @return string + */ + public static function touches(string $attribute, array $values): string + { + return (new Query('touches', $attribute, $values))->__toString(); + } + + /** + * Not Touches + * + * @param string $attribute + * @param array $values + * @return string + */ + public static function notTouches(string $attribute, array $values): string + { + return (new Query('notTouches', $attribute, $values))->__toString(); + } } From 1907c405300a80fadc74995a816b7b8d22c7de8f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Fri, 5 Sep 2025 22:01:08 +1200 Subject: [PATCH 4/6] Fix refs --- docs/databases.md | 2 +- docs/tablesdb.md | 12 ++++++------ src/Appwrite/Services/Databases.php | 2 +- src/Appwrite/Services/TablesDb.php | 12 ++++++------ 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/databases.md b/docs/databases.md index e96ad7c..42a92b1 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -478,7 +478,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/attributes/point ``` -** Create a geometric 2d point attribute. ** +** Create a geometric point attribute. ** ### Parameters diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 904424b..37d3b27 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -442,7 +442,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/line ``` -** Create a geometric line attribute. ** +** Create a geometric line column. ** ### Parameters @@ -459,7 +459,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/line/{key} ``` -** Update a line column. Changing the `default` value will not update already existing documents. ** +** Update a line column. Changing the `default` value will not update already existing rows. ** ### Parameters @@ -477,7 +477,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/point ``` -** Create a geometric point attribute. ** +** Create a geometric point column. ** ### Parameters @@ -494,7 +494,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/point/{key} ``` -** Update a point column. Changing the `default` value will not update already existing documents. ** +** Update a point column. Changing the `default` value will not update already existing rows. ** ### Parameters @@ -512,7 +512,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/polygon ``` -** Create a geometric polygon attribute. ** +** Create a geometric polygon column. ** ### Parameters @@ -529,7 +529,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns/polygon/{key} ``` -** Update a polygon column. Changing the `default` value will not update already existing documents. ** +** Update a polygon column. Changing the `default` value will not update already existing rows. ** ### Parameters diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index 64592ac..fd44c5f 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -1258,7 +1258,7 @@ public function updateLineAttribute(string $databaseId, string $collectionId, st } /** - * Create a geometric 2d point attribute. + * Create a geometric point attribute. * * @param string $databaseId * @param string $collectionId diff --git a/src/Appwrite/Services/TablesDb.php b/src/Appwrite/Services/TablesDb.php index 7430ad7..d44fb83 100644 --- a/src/Appwrite/Services/TablesDb.php +++ b/src/Appwrite/Services/TablesDb.php @@ -1096,7 +1096,7 @@ public function updateIpColumn(string $databaseId, string $tableId, string $key, } /** - * Create a geometric line attribute. + * Create a geometric line column. * * @param string $databaseId * @param string $tableId @@ -1134,7 +1134,7 @@ public function createLineColumn(string $databaseId, string $tableId, string $ke /** * Update a line column. Changing the `default` value will not update already - * existing documents. + * existing rows. * * @param string $databaseId * @param string $tableId @@ -1176,7 +1176,7 @@ public function updateLineColumn(string $databaseId, string $tableId, string $ke } /** - * Create a geometric point attribute. + * Create a geometric point column. * * @param string $databaseId * @param string $tableId @@ -1214,7 +1214,7 @@ public function createPointColumn(string $databaseId, string $tableId, string $k /** * Update a point column. Changing the `default` value will not update already - * existing documents. + * existing rows. * * @param string $databaseId * @param string $tableId @@ -1256,7 +1256,7 @@ public function updatePointColumn(string $databaseId, string $tableId, string $k } /** - * Create a geometric polygon attribute. + * Create a geometric polygon column. * * @param string $databaseId * @param string $tableId @@ -1294,7 +1294,7 @@ public function createPolygonColumn(string $databaseId, string $tableId, string /** * Update a polygon column. Changing the `default` value will not update - * already existing documents. + * already existing rows. * * @param string $databaseId * @param string $tableId From 61a844c75c1c58cad6eefa8556df7ea5d7a87ac8 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Sat, 6 Sep 2025 04:57:28 +1200 Subject: [PATCH 5/6] Fix spatial default --- docs/databases.md | 12 +++++----- docs/examples/account/update-prefs.md | 6 ++++- docs/examples/databases/create-document.md | 8 ++++++- .../databases/create-line-attribute.md | 2 +- .../databases/create-point-attribute.md | 2 +- .../databases/create-polygon-attribute.md | 2 +- .../databases/update-line-attribute.md | 2 +- .../databases/update-point-attribute.md | 2 +- .../databases/update-polygon-attribute.md | 2 +- docs/examples/tablesdb/create-line-column.md | 2 +- docs/examples/tablesdb/create-point-column.md | 2 +- .../tablesdb/create-polygon-column.md | 2 +- docs/examples/tablesdb/create-row.md | 8 ++++++- docs/examples/tablesdb/update-line-column.md | 2 +- docs/examples/tablesdb/update-point-column.md | 2 +- .../tablesdb/update-polygon-column.md | 2 +- docs/tablesdb.md | 12 +++++----- src/Appwrite/Services/Databases.php | 24 +++++++++---------- src/Appwrite/Services/TablesDb.php | 24 +++++++++---------- 19 files changed, 67 insertions(+), 51 deletions(-) diff --git a/docs/databases.md b/docs/databases.md index 42a92b1..e97a483 100644 --- a/docs/databases.md +++ b/docs/databases.md @@ -453,7 +453,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | 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, as JSON string. Cannot be set when attribute is required. | | +| default | array | Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. | | ```http request @@ -470,7 +470,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | 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 | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | +| default | array | Default value for attribute when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when attribute is required. | | | newKey | string | New attribute key. | | @@ -488,7 +488,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | 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, as JSON string. Cannot be set when attribute is required. | | +| default | array | Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. | | ```http request @@ -505,7 +505,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | 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 | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | +| default | array | Default value for attribute when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when attribute is required. | | | newKey | string | New attribute key. | | @@ -523,7 +523,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection | 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, as JSON string. Cannot be set when attribute is required. | | +| default | array | Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. | | ```http request @@ -540,7 +540,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio | 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 | string | Default value for attribute when not provided, as JSON string. Cannot be set when attribute is required. | | +| default | array | Default value for attribute when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when attribute is required. | | | newKey | string | New attribute key. | | diff --git a/docs/examples/account/update-prefs.md b/docs/examples/account/update-prefs.md index 698da0f..f6a1003 100644 --- a/docs/examples/account/update-prefs.md +++ b/docs/examples/account/update-prefs.md @@ -11,5 +11,9 @@ $client = (new Client()) $account = new Account($client); $result = $account->updatePrefs( - prefs: [] + prefs: [ + 'language' => 'en', + 'timezone' => 'UTC', + 'darkTheme' => true + ] ); \ No newline at end of file diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md index bf1ee3f..9f2e8f3 100644 --- a/docs/examples/databases/create-document.md +++ b/docs/examples/databases/create-document.md @@ -14,6 +14,12 @@ $result = $databases->createDocument( databaseId: '', collectionId: '', documentId: '', - data: [], + data: [ + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O'Brien', + 'age' => 30, + 'isAdmin' => false + ], permissions: ["read("any")"] // optional ); \ No newline at end of file diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index 5d4f968..de9e624 100644 --- a/docs/examples/databases/create-line-attribute.md +++ b/docs/examples/databases/create-line-attribute.md @@ -15,5 +15,5 @@ $result = $databases->createLineAttribute( collectionId: '', key: '', required: false, - default: '' // optional + default: [[1,2], [3, 4]] // optional ); \ No newline at end of file diff --git a/docs/examples/databases/create-point-attribute.md b/docs/examples/databases/create-point-attribute.md index 1c8cdb5..de3f3a4 100644 --- a/docs/examples/databases/create-point-attribute.md +++ b/docs/examples/databases/create-point-attribute.md @@ -15,5 +15,5 @@ $result = $databases->createPointAttribute( collectionId: '', key: '', required: false, - default: '' // optional + default: [[1,2], [3, 4]] // optional ); \ No newline at end of file diff --git a/docs/examples/databases/create-polygon-attribute.md b/docs/examples/databases/create-polygon-attribute.md index 0608d33..b79a48e 100644 --- a/docs/examples/databases/create-polygon-attribute.md +++ b/docs/examples/databases/create-polygon-attribute.md @@ -15,5 +15,5 @@ $result = $databases->createPolygonAttribute( collectionId: '', key: '', required: false, - default: '' // optional + default: [[1,2], [3, 4]] // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update-line-attribute.md b/docs/examples/databases/update-line-attribute.md index a5de545..e24e9e4 100644 --- a/docs/examples/databases/update-line-attribute.md +++ b/docs/examples/databases/update-line-attribute.md @@ -15,6 +15,6 @@ $result = $databases->updateLineAttribute( collectionId: '', key: '', required: false, - default: '', // optional + default: [[1,2], [3, 4]], // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update-point-attribute.md b/docs/examples/databases/update-point-attribute.md index 0499663..0a61026 100644 --- a/docs/examples/databases/update-point-attribute.md +++ b/docs/examples/databases/update-point-attribute.md @@ -15,6 +15,6 @@ $result = $databases->updatePointAttribute( collectionId: '', key: '', required: false, - default: '', // optional + default: [[1,2], [3, 4]], // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/examples/databases/update-polygon-attribute.md b/docs/examples/databases/update-polygon-attribute.md index 99c63f1..3bf5228 100644 --- a/docs/examples/databases/update-polygon-attribute.md +++ b/docs/examples/databases/update-polygon-attribute.md @@ -15,6 +15,6 @@ $result = $databases->updatePolygonAttribute( collectionId: '', key: '', required: false, - default: '', // optional + default: [[1,2], [3, 4]], // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-line-column.md b/docs/examples/tablesdb/create-line-column.md index daab57e..8d9353c 100644 --- a/docs/examples/tablesdb/create-line-column.md +++ b/docs/examples/tablesdb/create-line-column.md @@ -15,5 +15,5 @@ $result = $tablesDB->createLineColumn( tableId: '', key: '', required: false, - default: '' // optional + default: [[1,2], [3, 4]] // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-point-column.md b/docs/examples/tablesdb/create-point-column.md index 6b8cf1d..2832479 100644 --- a/docs/examples/tablesdb/create-point-column.md +++ b/docs/examples/tablesdb/create-point-column.md @@ -15,5 +15,5 @@ $result = $tablesDB->createPointColumn( tableId: '', key: '', required: false, - default: '' // optional + default: [[1,2], [3, 4]] // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-polygon-column.md b/docs/examples/tablesdb/create-polygon-column.md index 1114746..a6f685a 100644 --- a/docs/examples/tablesdb/create-polygon-column.md +++ b/docs/examples/tablesdb/create-polygon-column.md @@ -15,5 +15,5 @@ $result = $tablesDB->createPolygonColumn( tableId: '', key: '', required: false, - default: '' // optional + default: [[1,2], [3, 4]] // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md index 0002b79..fa5137b 100644 --- a/docs/examples/tablesdb/create-row.md +++ b/docs/examples/tablesdb/create-row.md @@ -14,6 +14,12 @@ $result = $tablesDB->createRow( databaseId: '', tableId: '', rowId: '', - data: [], + data: [ + 'username' => 'walter.obrien', + 'email' => 'walter.obrien@example.com', + 'fullName' => 'Walter O'Brien', + 'age' => 30, + 'isAdmin' => false + ], permissions: ["read("any")"] // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-line-column.md b/docs/examples/tablesdb/update-line-column.md index ac2584d..184fada 100644 --- a/docs/examples/tablesdb/update-line-column.md +++ b/docs/examples/tablesdb/update-line-column.md @@ -15,6 +15,6 @@ $result = $tablesDB->updateLineColumn( tableId: '', key: '', required: false, - default: '', // optional + default: [[1,2], [3, 4]], // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-point-column.md b/docs/examples/tablesdb/update-point-column.md index 159f893..4b1d73c 100644 --- a/docs/examples/tablesdb/update-point-column.md +++ b/docs/examples/tablesdb/update-point-column.md @@ -15,6 +15,6 @@ $result = $tablesDB->updatePointColumn( tableId: '', key: '', required: false, - default: '', // optional + default: [[1,2], [3, 4]], // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/examples/tablesdb/update-polygon-column.md b/docs/examples/tablesdb/update-polygon-column.md index 3f6f3e8..647fd27 100644 --- a/docs/examples/tablesdb/update-polygon-column.md +++ b/docs/examples/tablesdb/update-polygon-column.md @@ -15,6 +15,6 @@ $result = $tablesDB->updatePolygonColumn( tableId: '', key: '', required: false, - default: '', // optional + default: [[1,2], [3, 4]], // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 37d3b27..40dfded 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -452,7 +452,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | | key | string | Column Key. | | | required | boolean | Is column required? | | -| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| default | array | Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. | | ```http request @@ -469,7 +469,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | | key | string | **Required** Column Key. | | | required | boolean | Is column required? | | -| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| default | array | Default value for column when not provided, two-dimensional array of coordinate pairs, [[longitude, latitude], [longitude, latitude], …], listing the vertices of the line in order. Cannot be set when column is required. | | | newKey | string | New Column Key. | | @@ -487,7 +487,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | | key | string | Column Key. | | | required | boolean | Is column required? | | -| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| default | array | Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. | | ```http request @@ -504,7 +504,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | | key | string | **Required** Column Key. | | | required | boolean | Is column required? | | -| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| default | array | Default value for column when not provided, array of two numbers [longitude, latitude], representing a single coordinate. Cannot be set when column is required. | | | newKey | string | New Column Key. | | @@ -522,7 +522,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/columns | tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | | key | string | Column Key. | | | required | boolean | Is column required? | | -| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| default | array | Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. | | ```http request @@ -539,7 +539,7 @@ PATCH https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/column | tableId | string | **Required** Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). | | | key | string | **Required** Column Key. | | | required | boolean | Is column required? | | -| default | string | Default value for column when not provided, as JSON string. Cannot be set when column is required. | | +| default | array | Default value for column when not provided, three-dimensional array where the outer array holds one or more linear rings, [[[longitude, latitude], …], …], the first ring is the exterior boundary, any additional rings are interior holes, and each ring must start and end with the same coordinate pair. Cannot be set when column is required. | | | newKey | string | New Column Key. | | diff --git a/src/Appwrite/Services/Databases.php b/src/Appwrite/Services/Databases.php index fd44c5f..9c1b16e 100644 --- a/src/Appwrite/Services/Databases.php +++ b/src/Appwrite/Services/Databases.php @@ -1178,14 +1178,14 @@ public function updateIpAttribute(string $databaseId, string $collectionId, stri * @param string $collectionId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `createLineColumn` instead. * @see TablesDB::createLineColumn */ - public function createLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null): array + public function createLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1219,7 +1219,7 @@ public function createLineAttribute(string $databaseId, string $collectionId, st * @param string $collectionId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @param ?string $newKey * @throws AppwriteException * @return array @@ -1227,7 +1227,7 @@ public function createLineAttribute(string $databaseId, string $collectionId, st * @deprecated This API has been deprecated since 1.8.0. Please use `updateLineColumn` instead. * @see TablesDB::updateLineColumn */ - public function updateLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + public function updateLineAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], @@ -1264,14 +1264,14 @@ public function updateLineAttribute(string $databaseId, string $collectionId, st * @param string $collectionId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `createPointColumn` instead. * @see TablesDB::createPointColumn */ - public function createPointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null): array + public function createPointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1305,7 +1305,7 @@ public function createPointAttribute(string $databaseId, string $collectionId, s * @param string $collectionId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @param ?string $newKey * @throws AppwriteException * @return array @@ -1313,7 +1313,7 @@ public function createPointAttribute(string $databaseId, string $collectionId, s * @deprecated This API has been deprecated since 1.8.0. Please use `updatePointColumn` instead. * @see TablesDB::updatePointColumn */ - public function updatePointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + public function updatePointAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], @@ -1350,14 +1350,14 @@ public function updatePointAttribute(string $databaseId, string $collectionId, s * @param string $collectionId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @throws AppwriteException * @return array * * @deprecated This API has been deprecated since 1.8.0. Please use `createPolygonColumn` instead. * @see TablesDB::createPolygonColumn */ - public function createPolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null): array + public function createPolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}'], @@ -1391,7 +1391,7 @@ public function createPolygonAttribute(string $databaseId, string $collectionId, * @param string $collectionId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @param ?string $newKey * @throws AppwriteException * @return array @@ -1399,7 +1399,7 @@ public function createPolygonAttribute(string $databaseId, string $collectionId, * @deprecated This API has been deprecated since 1.8.0. Please use `updatePolygonColumn` instead. * @see TablesDB::updatePolygonColumn */ - public function updatePolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + public function updatePolygonAttribute(string $databaseId, string $collectionId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array { $apiPath = str_replace( ['{databaseId}', '{collectionId}', '{key}'], diff --git a/src/Appwrite/Services/TablesDb.php b/src/Appwrite/Services/TablesDb.php index d44fb83..0258f25 100644 --- a/src/Appwrite/Services/TablesDb.php +++ b/src/Appwrite/Services/TablesDb.php @@ -1102,11 +1102,11 @@ public function updateIpColumn(string $databaseId, string $tableId, string $key, * @param string $tableId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @throws AppwriteException * @return array */ - public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null): array + public function createLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -1140,12 +1140,12 @@ public function createLineColumn(string $databaseId, string $tableId, string $ke * @param string $tableId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @param ?string $newKey * @throws AppwriteException * @return array */ - public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + public function updateLineColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], @@ -1182,11 +1182,11 @@ public function updateLineColumn(string $databaseId, string $tableId, string $ke * @param string $tableId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @throws AppwriteException * @return array */ - public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null): array + public function createPointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -1220,12 +1220,12 @@ public function createPointColumn(string $databaseId, string $tableId, string $k * @param string $tableId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @param ?string $newKey * @throws AppwriteException * @return array */ - public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + public function updatePointColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], @@ -1262,11 +1262,11 @@ public function updatePointColumn(string $databaseId, string $tableId, string $k * @param string $tableId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @throws AppwriteException * @return array */ - public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null): array + public function createPolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}'], @@ -1300,12 +1300,12 @@ public function createPolygonColumn(string $databaseId, string $tableId, string * @param string $tableId * @param string $key * @param bool $required - * @param ?string $xdefault + * @param ?array $xdefault * @param ?string $newKey * @throws AppwriteException * @return array */ - public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?string $xdefault = null, ?string $newKey = null): array + public function updatePolygonColumn(string $databaseId, string $tableId, string $key, bool $required, ?array $xdefault = null, ?string $newKey = null): array { $apiPath = str_replace( ['{databaseId}', '{tableId}', '{key}'], From 1cddfd12ad9364d2619c0886dfa6212d7aab542f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 8 Sep 2025 21:41:51 +1200 Subject: [PATCH 6/6] Update spatial queries --- src/Appwrite/Query.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index c714c82..c49575c 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -434,7 +434,7 @@ public static function and(array $queries): string */ public static function distanceEqual(string $attribute, array $values, int|float $distance, bool $meters = true): string { - return (new Query('distanceEqual', $attribute, [$values, $distance, $meters]))->__toString(); + return (new Query('distanceEqual', $attribute, [[$values, $distance, $meters]]))->__toString(); } /** @@ -447,7 +447,7 @@ public static function distanceEqual(string $attribute, array $values, int|float */ public static function distanceNotEqual(string $attribute, array $values, int|float $distance, bool $meters = true): string { - return (new Query('distanceNotEqual', $attribute, [$values, $distance, $meters]))->__toString(); + return (new Query('distanceNotEqual', $attribute, [[$values, $distance, $meters]]))->__toString(); } /** @@ -460,7 +460,7 @@ public static function distanceNotEqual(string $attribute, array $values, int|fl */ public static function distanceGreaterThan(string $attribute, array $values, int|float $distance, bool $meters = true): string { - return (new Query('distanceGreaterThan', $attribute, [$values, $distance, $meters]))->__toString(); + return (new Query('distanceGreaterThan', $attribute, [[$values, $distance, $meters]]))->__toString(); } /** @@ -474,7 +474,7 @@ public static function distanceGreaterThan(string $attribute, array $values, int */ public static function distanceLessThan(string $attribute, array $values, int|float $distance, bool $meters = true): string { - return (new Query('distanceLessThan', $attribute, [$values, $distance, $meters]))->__toString(); + return (new Query('distanceLessThan', $attribute, [[$values, $distance, $meters]]))->__toString(); } /** @@ -486,7 +486,7 @@ public static function distanceLessThan(string $attribute, array $values, int|fl */ public static function intersects(string $attribute, array $values): string { - return (new Query('intersects', $attribute, $values))->__toString(); + return (new Query('intersects', $attribute, [$values]))->__toString(); } /** @@ -498,7 +498,7 @@ public static function intersects(string $attribute, array $values): string */ public static function notIntersects(string $attribute, array $values): string { - return (new Query('notIntersects', $attribute, $values))->__toString(); + return (new Query('notIntersects', $attribute, [$values]))->__toString(); } /** @@ -510,7 +510,7 @@ public static function notIntersects(string $attribute, array $values): string */ public static function crosses(string $attribute, array $values): string { - return (new Query('crosses', $attribute, $values))->__toString(); + return (new Query('crosses', $attribute, [$values]))->__toString(); } /** @@ -522,7 +522,7 @@ public static function crosses(string $attribute, array $values): string */ public static function notCrosses(string $attribute, array $values): string { - return (new Query('notCrosses', $attribute, $values))->__toString(); + return (new Query('notCrosses', $attribute, [$values]))->__toString(); } /** @@ -534,7 +534,7 @@ public static function notCrosses(string $attribute, array $values): string */ public static function overlaps(string $attribute, array $values): string { - return (new Query('overlaps', $attribute, $values))->__toString(); + return (new Query('overlaps', $attribute, [$values]))->__toString(); } /** @@ -546,7 +546,7 @@ public static function overlaps(string $attribute, array $values): string */ public static function notOverlaps(string $attribute, array $values): string { - return (new Query('notOverlaps', $attribute, $values))->__toString(); + return (new Query('notOverlaps', $attribute, [$values]))->__toString(); } /** @@ -558,7 +558,7 @@ public static function notOverlaps(string $attribute, array $values): string */ public static function touches(string $attribute, array $values): string { - return (new Query('touches', $attribute, $values))->__toString(); + return (new Query('touches', $attribute, [$values]))->__toString(); } /** @@ -570,6 +570,6 @@ public static function touches(string $attribute, array $values): string */ public static function notTouches(string $attribute, array $values): string { - return (new Query('notTouches', $attribute, $values))->__toString(); + return (new Query('notTouches', $attribute, [$values]))->__toString(); } }