From 21d7a0fe5dc8520b119d60fc6b3b666a2a9acc1d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 23 Sep 2025 15:21:38 +1200 Subject: [PATCH] Add order random --- docs/examples/databases/create-line-attribute.md | 2 +- docs/examples/databases/create-point-attribute.md | 2 +- docs/examples/databases/create-polygon-attribute.md | 2 +- docs/examples/databases/update-line-attribute.md | 2 +- docs/examples/databases/update-point-attribute.md | 2 +- docs/examples/databases/update-polygon-attribute.md | 2 +- docs/examples/tablesdb/create-line-column.md | 2 +- docs/examples/tablesdb/create-point-column.md | 2 +- docs/examples/tablesdb/create-polygon-column.md | 2 +- docs/examples/tablesdb/update-line-column.md | 2 +- docs/examples/tablesdb/update-point-column.md | 2 +- docs/examples/tablesdb/update-polygon-column.md | 2 +- docs/tablesdb.md | 2 +- src/Appwrite/Client.php | 4 ++-- src/Appwrite/Query.php | 10 ++++++++++ tests/Appwrite/QueryTest.php | 4 ++++ tests/Appwrite/Services/FunctionsTest.php | 12 ++++++------ tests/Appwrite/Services/SitesTest.php | 12 ++++++------ 18 files changed, 41 insertions(+), 27 deletions(-) diff --git a/docs/examples/databases/create-line-attribute.md b/docs/examples/databases/create-line-attribute.md index de9e624..56d007c 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: [[1,2], [3, 4]] // optional + default: [[1, 2], [3, 4], [5, 6]] // 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 de3f3a4..dee0801 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: [[1,2], [3, 4]] // optional + default: [1, 2] // 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 b79a48e..d745589 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: [[1,2], [3, 4]] // optional + default: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // 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 e24e9e4..86b8f64 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: [[1,2], [3, 4]], // optional + default: [[1, 2], [3, 4], [5, 6]], // 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 0a61026..cdff226 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: [[1,2], [3, 4]], // optional + default: [1, 2], // 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 3bf5228..c2736bd 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: [[1,2], [3, 4]], // optional + default: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // 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 8d9353c..69f2e66 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: [[1,2], [3, 4]] // optional + default: [[1, 2], [3, 4], [5, 6]] // 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 2832479..006c9e0 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: [[1,2], [3, 4]] // optional + default: [1, 2] // 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 a6f685a..20fb271 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: [[1,2], [3, 4]] // optional + default: [[[1, 2], [3, 4], [5, 6], [1, 2]]] // 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 184fada..56a557c 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: [[1,2], [3, 4]], // optional + default: [[1, 2], [3, 4], [5, 6]], // 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 4b1d73c..abe8b73 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: [[1,2], [3, 4]], // optional + default: [1, 2], // 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 647fd27..2ff4011 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: [[1,2], [3, 4]], // optional + default: [[[1, 2], [3, 4], [5, 6], [1, 2]]], // optional newKey: '' // optional ); \ No newline at end of file diff --git a/docs/tablesdb.md b/docs/tablesdb.md index 40dfded..28b154e 100644 --- a/docs/tablesdb.md +++ b/docs/tablesdb.md @@ -800,7 +800,7 @@ POST https://cloud.appwrite.io/v1/tablesdb/{databaseId}/tables/{tableId}/rows | --- | --- | --- | --- | | databaseId | string | **Required** Database ID. | | | tableId | string | **Required** Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/server/tablesdb#tablesDBCreate). Make sure to define columns before creating rows. | | -| rows | array | Array of documents data as JSON objects. | [] | +| rows | array | Array of rows data as JSON objects. | [] | ```http request diff --git a/src/Appwrite/Client.php b/src/Appwrite/Client.php index 49aa1ae..62534df 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/17.0.0 ()', + 'user-agent' => 'AppwritePHPSDK/17.1.0 ()', 'x-sdk-name'=> 'PHP', 'x-sdk-platform'=> 'server', 'x-sdk-language'=> 'php', - 'x-sdk-version'=> '17.0.0', + 'x-sdk-version'=> '17.1.0', ]; /** diff --git a/src/Appwrite/Query.php b/src/Appwrite/Query.php index c49575c..51dd712 100644 --- a/src/Appwrite/Query.php +++ b/src/Appwrite/Query.php @@ -233,6 +233,16 @@ public static function orderDesc(string $attribute): string return (new Query('orderDesc', $attribute, null))->__toString(); } + /** + * Order Random + * + * @return string + */ + public static function orderRandom(): string + { + return (new Query('orderRandom', null, null))->__toString(); + } + /** * Limit * diff --git a/tests/Appwrite/QueryTest.php b/tests/Appwrite/QueryTest.php index 01332ef..60bdaa6 100644 --- a/tests/Appwrite/QueryTest.php +++ b/tests/Appwrite/QueryTest.php @@ -131,6 +131,10 @@ public function testOrderDesc(): void { $this->assertSame('orderDesc("attr")', Query::orderDesc('attr')); } + public function testOrderRandom(): void { + $this->assertSame('{"method":"orderRandom"}', Query::orderRandom()); + } + public function testCursorBefore(): void { $this->assertSame('cursorBefore("attr")', Query::cursorBefore('attr')); } diff --git a/tests/Appwrite/Services/FunctionsTest.php b/tests/Appwrite/Services/FunctionsTest.php index e3f7b91..23ed641 100644 --- a/tests/Appwrite/Services/FunctionsTest.php +++ b/tests/Appwrite/Services/FunctionsTest.php @@ -304,12 +304,12 @@ public function testMethodCreateDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -349,12 +349,12 @@ public function testMethodCreateDuplicateDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -393,12 +393,12 @@ public function testMethodCreateTemplateDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -440,12 +440,12 @@ public function testMethodCreateVcsDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -485,12 +485,12 @@ public function testMethodGetDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -563,12 +563,12 @@ public function testMethodUpdateDeploymentStatus(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); diff --git a/tests/Appwrite/Services/SitesTest.php b/tests/Appwrite/Services/SitesTest.php index 4768471..6a9d15a 100644 --- a/tests/Appwrite/Services/SitesTest.php +++ b/tests/Appwrite/Services/SitesTest.php @@ -310,12 +310,12 @@ public function testMethodCreateDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -355,12 +355,12 @@ public function testMethodCreateDuplicateDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -399,12 +399,12 @@ public function testMethodCreateTemplateDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -446,12 +446,12 @@ public function testMethodCreateVcsDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -491,12 +491,12 @@ public function testMethodGetDeployment(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",); @@ -569,12 +569,12 @@ public function testMethodUpdateDeploymentStatus(): void { "providerRepositoryName" => "database", "providerRepositoryOwner" => "utopia", "providerRepositoryUrl" => "https://github.com/vermakhushboo/g4-node-function", - "providerBranch" => "0.7.x", "providerCommitHash" => "7c3f25d", "providerCommitAuthorUrl" => "https://github.com/vermakhushboo", "providerCommitAuthor" => "Khushboo Verma", "providerCommitMessage" => "Update index.js", "providerCommitUrl" => "https://github.com/vermakhushboo/g4-node-function/commit/60c0416257a9cbcdd96b2d370c38d8f8d150ccfb", + "providerBranch" => "0.7.x", "providerBranchUrl" => "https://github.com/vermakhushboo/appwrite/tree/0.7.x",);