Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 17.4.0

* Add transaction support for Databases and TablesDB

## 17.3.0

* Deprecate `createVerification` method in `Account` service
Expand Down
95 changes: 94 additions & 1 deletion docs/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,87 @@ POST https://cloud.appwrite.io/v1/databases
| enabled | boolean | Is the database enabled? When set to 'disabled', users cannot access the database but Server SDKs with an API key can still read and write to the database. No data is lost when this is toggled. | 1 |


```http request
GET https://cloud.appwrite.io/v1/databases/transactions
```

** List transactions across all databases. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). | [] |


```http request
POST https://cloud.appwrite.io/v1/databases/transactions
```

** Create a new transaction. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| ttl | integer | Seconds before the transaction expires. | 300 |


```http request
GET https://cloud.appwrite.io/v1/databases/transactions/{transactionId}
```

** Get a transaction by its unique ID. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| transactionId | string | **Required** Transaction ID. | |


```http request
PATCH https://cloud.appwrite.io/v1/databases/transactions/{transactionId}
```

** Update a transaction, to either commit or roll back its operations. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| transactionId | string | **Required** Transaction ID. | |
| commit | boolean | Commit transaction? | |
| rollback | boolean | Rollback transaction? | |


```http request
DELETE https://cloud.appwrite.io/v1/databases/transactions/{transactionId}
```

** Delete a transaction by its unique ID. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| transactionId | string | **Required** Transaction ID. | |


```http request
POST https://cloud.appwrite.io/v1/databases/transactions/{transactionId}/operations
```

** Create multiple operations in a single transaction. **

### Parameters

| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| transactionId | string | **Required** Transaction ID. | |
| operations | array | Array of staged operations. | [] |


```http request
GET https://cloud.appwrite.io/v1/databases/{databaseId}
```
Expand Down Expand Up @@ -705,6 +786,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI
| 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). | |
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] |
| transactionId | string | Transaction ID to read uncommitted changes within the transaction. | |


```http request
Expand All @@ -722,6 +804,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection
| documentId | string | Document ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. | |
| data | object | Document data as JSON object. | {} |
| permissions | array | An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions). | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -737,6 +820,7 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection
| 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). Make sure to define attributes before creating documents. | |
| documents | array | Array of documents data as JSON objects. | [] |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -753,6 +837,7 @@ PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI
| databaseId | string | **Required** Database ID. | |
| collectionId | string | **Required** Collection ID. | |
| documents | array | Array of document data as JSON objects. May contain partial documents. | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -769,6 +854,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio
| collectionId | string | **Required** Collection ID. | |
| data | object | Document data as JSON object. Include only attribute and value pairs to be updated. | {} |
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -784,6 +870,7 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti
| 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). | |
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -800,6 +887,7 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI
| collectionId | string | **Required** Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). | |
| documentId | string | **Required** Document ID. | |
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] |
| transactionId | string | Transaction ID to read uncommitted changes within the transaction. | |


```http request
Expand All @@ -817,6 +905,7 @@ PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI
| documentId | string | **Required** Document ID. | |
| data | object | Document data as JSON object. Include all required attributes of the document to be created or updated. | {} |
| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -834,6 +923,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio
| documentId | string | **Required** Document ID. | |
| data | object | Document data as JSON object. Include only attribute and value pairs to be updated. | {} |
| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -849,6 +939,7 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti
| 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). | |
| documentId | string | **Required** Document ID. | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -867,6 +958,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio
| attribute | string | **Required** Attribute key. | |
| value | number | Value to increment the attribute by. The value must be a number. | 1 |
| min | number | Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand All @@ -885,6 +977,7 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio
| attribute | string | **Required** Attribute key. | |
| value | number | Value to increment the attribute by. The value must be a number. | 1 |
| max | number | Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. | |
| transactionId | string | Transaction ID for staging the operation. | |


```http request
Expand Down Expand Up @@ -926,7 +1019,7 @@ Attributes can be `key`, `fulltext`, and `unique`. **
GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes/{key}
```

** Get index by ID. **
** Get an index by its unique ID. **

### Parameters

Expand Down
3 changes: 2 additions & 1 deletion docs/examples/databases/create-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ $result = $databases->createDocument(
'age' => 30,
'isAdmin' => false
],
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
);
3 changes: 2 additions & 1 deletion docs/examples/databases/create-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ $databases = new Databases($client);
$result = $databases->createDocuments(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documents: []
documents: [],
transactionId: '<TRANSACTION_ID>' // optional
);
26 changes: 26 additions & 0 deletions docs/examples/databases/create-operations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$databases = new Databases($client);

$result = $databases->createOperations(
transactionId: '<TRANSACTION_ID>',
operations: [
{
"action": "create",
"databaseId": "<DATABASE_ID>",
"collectionId": "<COLLECTION_ID>",
"documentId": "<DOCUMENT_ID>",
"data": {
"name": "Walter O'Brien"
}
}
] // optional
);
15 changes: 15 additions & 0 deletions docs/examples/databases/create-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$databases = new Databases($client);

$result = $databases->createTransaction(
ttl: 60 // optional
);
3 changes: 2 additions & 1 deletion docs/examples/databases/decrement-document-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ $result = $databases->decrementDocumentAttribute(
documentId: '<DOCUMENT_ID>',
attribute: '',
value: null, // optional
min: null // optional
min: null, // optional
transactionId: '<TRANSACTION_ID>' // optional
);
3 changes: 2 additions & 1 deletion docs/examples/databases/delete-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ $databases = new Databases($client);
$result = $databases->deleteDocument(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>'
documentId: '<DOCUMENT_ID>',
transactionId: '<TRANSACTION_ID>' // optional
);
3 changes: 2 additions & 1 deletion docs/examples/databases/delete-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ $databases = new Databases($client);
$result = $databases->deleteDocuments(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
queries: [] // optional
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
);
15 changes: 15 additions & 0 deletions docs/examples/databases/delete-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$databases = new Databases($client);

$result = $databases->deleteTransaction(
transactionId: '<TRANSACTION_ID>'
);
3 changes: 2 additions & 1 deletion docs/examples/databases/get-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ $result = $databases->getDocument(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
queries: [] // optional
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
);
15 changes: 15 additions & 0 deletions docs/examples/databases/get-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$databases = new Databases($client);

$result = $databases->getTransaction(
transactionId: '<TRANSACTION_ID>'
);
3 changes: 2 additions & 1 deletion docs/examples/databases/increment-document-attribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ $result = $databases->incrementDocumentAttribute(
documentId: '<DOCUMENT_ID>',
attribute: '',
value: null, // optional
max: null // optional
max: null, // optional
transactionId: '<TRANSACTION_ID>' // optional
);
3 changes: 2 additions & 1 deletion docs/examples/databases/list-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ $databases = new Databases($client);
$result = $databases->listDocuments(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
queries: [] // optional
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
);
15 changes: 15 additions & 0 deletions docs/examples/databases/list-transactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

use Appwrite\Client;
use Appwrite\Services\Databases;

$client = (new Client())
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
->setProject('<YOUR_PROJECT_ID>') // Your project ID
->setKey('<YOUR_API_KEY>'); // Your secret API key

$databases = new Databases($client);

$result = $databases->listTransactions(
queries: [] // optional
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ $result = $databases->updateDocument(
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
data: [], // optional
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ $result = $databases->updateDocuments(
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
data: [], // optional
queries: [] // optional
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
);
Loading