diff --git a/CHANGELOG.md b/CHANGELOG.md
index a28d868..b88265d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Change Log
+## 21.2.0
+
+* Add transaction support for Databases and TablesDB
+
## 21.1.0
* Deprecate `createVerification` method in `Account` service
diff --git a/README.md b/README.md
index a32085a..a9fe1b6 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ import { Client, Account } from "appwrite";
To install with a CDN (content delivery network) add the following scripts to the bottom of your
tag, but before you use any Appwrite services:
```html
-
+
```
diff --git a/docs/examples/databases/create-document.md b/docs/examples/databases/create-document.md
index 08606c9..8417575 100644
--- a/docs/examples/databases/create-document.md
+++ b/docs/examples/databases/create-document.md
@@ -17,7 +17,8 @@ const result = await databases.createDocument({
"age": 30,
"isAdmin": false
},
- permissions: ["read("any")"] // optional
+ permissions: ["read("any")"], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/databases/create-operations.md b/docs/examples/databases/create-operations.md
new file mode 100644
index 0000000..2ebc085
--- /dev/null
+++ b/docs/examples/databases/create-operations.md
@@ -0,0 +1,24 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const databases = new Databases(client);
+
+const result = await databases.createOperations({
+ transactionId: '',
+ operations: [
+ {
+ "action": "create",
+ "databaseId": "",
+ "collectionId": "",
+ "documentId": "",
+ "data": {
+ "name": "Walter O'Brien"
+ }
+ }
+ ] // optional
+});
+
+console.log(result);
diff --git a/docs/examples/databases/create-transaction.md b/docs/examples/databases/create-transaction.md
new file mode 100644
index 0000000..5371412
--- /dev/null
+++ b/docs/examples/databases/create-transaction.md
@@ -0,0 +1,13 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const databases = new Databases(client);
+
+const result = await databases.createTransaction({
+ ttl: 60 // optional
+});
+
+console.log(result);
diff --git a/docs/examples/databases/decrement-document-attribute.md b/docs/examples/databases/decrement-document-attribute.md
index 98629c4..f8e0ae9 100644
--- a/docs/examples/databases/decrement-document-attribute.md
+++ b/docs/examples/databases/decrement-document-attribute.md
@@ -12,7 +12,8 @@ const result = await databases.decrementDocumentAttribute({
documentId: '',
attribute: '',
value: null, // optional
- min: null // optional
+ min: null, // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/databases/delete-document.md b/docs/examples/databases/delete-document.md
index 4192085..4d10afd 100644
--- a/docs/examples/databases/delete-document.md
+++ b/docs/examples/databases/delete-document.md
@@ -9,7 +9,8 @@ const databases = new Databases(client);
const result = await databases.deleteDocument({
databaseId: '',
collectionId: '',
- documentId: ''
+ documentId: '',
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/databases/delete-transaction.md b/docs/examples/databases/delete-transaction.md
new file mode 100644
index 0000000..afe55c5
--- /dev/null
+++ b/docs/examples/databases/delete-transaction.md
@@ -0,0 +1,13 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const databases = new Databases(client);
+
+const result = await databases.deleteTransaction({
+ transactionId: ''
+});
+
+console.log(result);
diff --git a/docs/examples/databases/get-document.md b/docs/examples/databases/get-document.md
index b3a7558..5a44aeb 100644
--- a/docs/examples/databases/get-document.md
+++ b/docs/examples/databases/get-document.md
@@ -10,7 +10,8 @@ const result = await databases.getDocument({
databaseId: '',
collectionId: '',
documentId: '',
- queries: [] // optional
+ queries: [], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/databases/get-transaction.md b/docs/examples/databases/get-transaction.md
new file mode 100644
index 0000000..cc51199
--- /dev/null
+++ b/docs/examples/databases/get-transaction.md
@@ -0,0 +1,13 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const databases = new Databases(client);
+
+const result = await databases.getTransaction({
+ transactionId: ''
+});
+
+console.log(result);
diff --git a/docs/examples/databases/increment-document-attribute.md b/docs/examples/databases/increment-document-attribute.md
index 8adb5d8..eaf718e 100644
--- a/docs/examples/databases/increment-document-attribute.md
+++ b/docs/examples/databases/increment-document-attribute.md
@@ -12,7 +12,8 @@ const result = await databases.incrementDocumentAttribute({
documentId: '',
attribute: '',
value: null, // optional
- max: null // optional
+ max: null, // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/databases/list-documents.md b/docs/examples/databases/list-documents.md
index fb1d508..ece656a 100644
--- a/docs/examples/databases/list-documents.md
+++ b/docs/examples/databases/list-documents.md
@@ -9,7 +9,8 @@ const databases = new Databases(client);
const result = await databases.listDocuments({
databaseId: '',
collectionId: '',
- queries: [] // optional
+ queries: [], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/databases/list-transactions.md b/docs/examples/databases/list-transactions.md
new file mode 100644
index 0000000..f2ce1f7
--- /dev/null
+++ b/docs/examples/databases/list-transactions.md
@@ -0,0 +1,13 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const databases = new Databases(client);
+
+const result = await databases.listTransactions({
+ queries: [] // optional
+});
+
+console.log(result);
diff --git a/docs/examples/databases/update-document.md b/docs/examples/databases/update-document.md
index bf35548..33a6d73 100644
--- a/docs/examples/databases/update-document.md
+++ b/docs/examples/databases/update-document.md
@@ -11,7 +11,8 @@ const result = await databases.updateDocument({
collectionId: '',
documentId: '',
data: {}, // optional
- permissions: ["read("any")"] // optional
+ permissions: ["read("any")"], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/databases/update-transaction.md b/docs/examples/databases/update-transaction.md
new file mode 100644
index 0000000..9274b0f
--- /dev/null
+++ b/docs/examples/databases/update-transaction.md
@@ -0,0 +1,15 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const databases = new Databases(client);
+
+const result = await databases.updateTransaction({
+ transactionId: '',
+ commit: false, // optional
+ rollback: false // optional
+});
+
+console.log(result);
diff --git a/docs/examples/databases/upsert-document.md b/docs/examples/databases/upsert-document.md
index c56bc55..e14ad5f 100644
--- a/docs/examples/databases/upsert-document.md
+++ b/docs/examples/databases/upsert-document.md
@@ -11,7 +11,8 @@ const result = await databases.upsertDocument({
collectionId: '',
documentId: '',
data: {},
- permissions: ["read("any")"] // optional
+ permissions: ["read("any")"], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/tablesdb/create-operations.md b/docs/examples/tablesdb/create-operations.md
new file mode 100644
index 0000000..c25b051
--- /dev/null
+++ b/docs/examples/tablesdb/create-operations.md
@@ -0,0 +1,24 @@
+import { Client, TablesDB } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const tablesDB = new TablesDB(client);
+
+const result = await tablesDB.createOperations({
+ transactionId: '',
+ operations: [
+ {
+ "action": "create",
+ "databaseId": "",
+ "tableId": "",
+ "rowId": "",
+ "data": {
+ "name": "Walter O'Brien"
+ }
+ }
+ ] // optional
+});
+
+console.log(result);
diff --git a/docs/examples/tablesdb/create-row.md b/docs/examples/tablesdb/create-row.md
index 1dd1fe4..3bbcf89 100644
--- a/docs/examples/tablesdb/create-row.md
+++ b/docs/examples/tablesdb/create-row.md
@@ -17,7 +17,8 @@ const result = await tablesDB.createRow({
"age": 30,
"isAdmin": false
},
- permissions: ["read("any")"] // optional
+ permissions: ["read("any")"], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/tablesdb/create-transaction.md b/docs/examples/tablesdb/create-transaction.md
new file mode 100644
index 0000000..17787dc
--- /dev/null
+++ b/docs/examples/tablesdb/create-transaction.md
@@ -0,0 +1,13 @@
+import { Client, TablesDB } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const tablesDB = new TablesDB(client);
+
+const result = await tablesDB.createTransaction({
+ ttl: 60 // optional
+});
+
+console.log(result);
diff --git a/docs/examples/tablesdb/decrement-row-column.md b/docs/examples/tablesdb/decrement-row-column.md
index 59f66d9..d6c6464 100644
--- a/docs/examples/tablesdb/decrement-row-column.md
+++ b/docs/examples/tablesdb/decrement-row-column.md
@@ -12,7 +12,8 @@ const result = await tablesDB.decrementRowColumn({
rowId: '',
column: '',
value: null, // optional
- min: null // optional
+ min: null, // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/tablesdb/delete-row.md b/docs/examples/tablesdb/delete-row.md
index 637114d..54c005c 100644
--- a/docs/examples/tablesdb/delete-row.md
+++ b/docs/examples/tablesdb/delete-row.md
@@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client);
const result = await tablesDB.deleteRow({
databaseId: '',
tableId: '',
- rowId: ''
+ rowId: '',
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/tablesdb/delete-transaction.md b/docs/examples/tablesdb/delete-transaction.md
new file mode 100644
index 0000000..2ff1198
--- /dev/null
+++ b/docs/examples/tablesdb/delete-transaction.md
@@ -0,0 +1,13 @@
+import { Client, TablesDB } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const tablesDB = new TablesDB(client);
+
+const result = await tablesDB.deleteTransaction({
+ transactionId: ''
+});
+
+console.log(result);
diff --git a/docs/examples/tablesdb/get-row.md b/docs/examples/tablesdb/get-row.md
index 4e43643..b345d14 100644
--- a/docs/examples/tablesdb/get-row.md
+++ b/docs/examples/tablesdb/get-row.md
@@ -10,7 +10,8 @@ const result = await tablesDB.getRow({
databaseId: '',
tableId: '',
rowId: '',
- queries: [] // optional
+ queries: [], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/tablesdb/get-transaction.md b/docs/examples/tablesdb/get-transaction.md
new file mode 100644
index 0000000..8e2f24c
--- /dev/null
+++ b/docs/examples/tablesdb/get-transaction.md
@@ -0,0 +1,13 @@
+import { Client, TablesDB } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const tablesDB = new TablesDB(client);
+
+const result = await tablesDB.getTransaction({
+ transactionId: ''
+});
+
+console.log(result);
diff --git a/docs/examples/tablesdb/increment-row-column.md b/docs/examples/tablesdb/increment-row-column.md
index a7f3a8c..5baca80 100644
--- a/docs/examples/tablesdb/increment-row-column.md
+++ b/docs/examples/tablesdb/increment-row-column.md
@@ -12,7 +12,8 @@ const result = await tablesDB.incrementRowColumn({
rowId: '',
column: '',
value: null, // optional
- max: null // optional
+ max: null, // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/tablesdb/list-rows.md b/docs/examples/tablesdb/list-rows.md
index 63149aa..c0efd84 100644
--- a/docs/examples/tablesdb/list-rows.md
+++ b/docs/examples/tablesdb/list-rows.md
@@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client);
const result = await tablesDB.listRows({
databaseId: '',
tableId: '',
- queries: [] // optional
+ queries: [], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/tablesdb/list-transactions.md b/docs/examples/tablesdb/list-transactions.md
new file mode 100644
index 0000000..fbf0908
--- /dev/null
+++ b/docs/examples/tablesdb/list-transactions.md
@@ -0,0 +1,13 @@
+import { Client, TablesDB } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const tablesDB = new TablesDB(client);
+
+const result = await tablesDB.listTransactions({
+ queries: [] // optional
+});
+
+console.log(result);
diff --git a/docs/examples/tablesdb/update-row.md b/docs/examples/tablesdb/update-row.md
index 1dba006..ecbcd4f 100644
--- a/docs/examples/tablesdb/update-row.md
+++ b/docs/examples/tablesdb/update-row.md
@@ -11,7 +11,8 @@ const result = await tablesDB.updateRow({
tableId: '',
rowId: '',
data: {}, // optional
- permissions: ["read("any")"] // optional
+ permissions: ["read("any")"], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/docs/examples/tablesdb/update-transaction.md b/docs/examples/tablesdb/update-transaction.md
new file mode 100644
index 0000000..2d987e4
--- /dev/null
+++ b/docs/examples/tablesdb/update-transaction.md
@@ -0,0 +1,15 @@
+import { Client, TablesDB } from "appwrite";
+
+const client = new Client()
+ .setEndpoint('https://.cloud.appwrite.io/v1') // Your API Endpoint
+ .setProject(''); // Your project ID
+
+const tablesDB = new TablesDB(client);
+
+const result = await tablesDB.updateTransaction({
+ transactionId: '',
+ commit: false, // optional
+ rollback: false // optional
+});
+
+console.log(result);
diff --git a/docs/examples/tablesdb/upsert-row.md b/docs/examples/tablesdb/upsert-row.md
index 1add1c4..ddac9ff 100644
--- a/docs/examples/tablesdb/upsert-row.md
+++ b/docs/examples/tablesdb/upsert-row.md
@@ -11,7 +11,8 @@ const result = await tablesDB.upsertRow({
tableId: '',
rowId: '',
data: {}, // optional
- permissions: ["read("any")"] // optional
+ permissions: ["read("any")"], // optional
+ transactionId: '' // optional
});
console.log(result);
diff --git a/package.json b/package.json
index abb4b76..c6afd25 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "appwrite",
"homepage": "https://appwrite.io/support",
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
- "version": "21.1.0",
+ "version": "21.2.0",
"license": "BSD-3-Clause",
"main": "dist/cjs/sdk.js",
"exports": {
diff --git a/src/client.ts b/src/client.ts
index 85b6cf4..35e04bd 100644
--- a/src/client.ts
+++ b/src/client.ts
@@ -316,7 +316,7 @@ class Client {
'x-sdk-name': 'Web',
'x-sdk-platform': 'client',
'x-sdk-language': 'web',
- 'x-sdk-version': '21.1.0',
+ 'x-sdk-version': '21.2.0',
'X-Appwrite-Response-Format': '1.8.0',
};
diff --git a/src/models.ts b/src/models.ts
index 65cbf00..d0c2d2a 100644
--- a/src/models.ts
+++ b/src/models.ts
@@ -218,6 +218,20 @@ export namespace Models {
localeCodes: LocaleCode[];
}
+ /**
+ * Transaction List
+ */
+ export type TransactionList = {
+ /**
+ * Total number of transactions that matched your query.
+ */
+ total: number;
+ /**
+ * List of transactions.
+ */
+ transactions: Transaction[];
+ }
+
/**
* Row
*/
@@ -1241,6 +1255,36 @@ export namespace Models {
recoveryCode: boolean;
}
+ /**
+ * Transaction
+ */
+ export type Transaction = {
+ /**
+ * Transaction ID.
+ */
+ $id: string;
+ /**
+ * Transaction creation time in ISO 8601 format.
+ */
+ $createdAt: string;
+ /**
+ * Transaction update date in ISO 8601 format.
+ */
+ $updatedAt: string;
+ /**
+ * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed.
+ */
+ status: string;
+ /**
+ * Number of operations in the transaction.
+ */
+ operations: number;
+ /**
+ * Expiration time in ISO 8601 format.
+ */
+ expiresAt: string;
+ }
+
/**
* Subscriber
*/
diff --git a/src/services/databases.ts b/src/services/databases.ts
index 7c22963..fc48bbf 100644
--- a/src/services/databases.ts
+++ b/src/services/databases.ts
@@ -10,47 +10,384 @@ export class Databases {
this.client = client;
}
+ /**
+ * List transactions across all databases.
+ *
+ * @param {string[]} params.queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries).
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ listTransactions(params?: { queries?: string[] }): Promise;
+ /**
+ * List transactions across all databases.
+ *
+ * @param {string[]} queries - Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries).
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ listTransactions(queries?: string[]): Promise;
+ listTransactions(
+ paramsOrFirst?: { queries?: string[] } | string[]
+ ): Promise {
+ let params: { queries?: string[] };
+
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
+ params = (paramsOrFirst || {}) as { queries?: string[] };
+ } else {
+ params = {
+ queries: paramsOrFirst as string[]
+ };
+ }
+
+ const queries = params.queries;
+
+
+ const apiPath = '/databases/transactions';
+ const payload: Payload = {};
+ if (typeof queries !== 'undefined') {
+ payload['queries'] = queries;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ }
+
+ return this.client.call(
+ 'get',
+ uri,
+ apiHeaders,
+ payload
+ );
+ }
+
+ /**
+ * Create a new transaction.
+ *
+ * @param {number} params.ttl - Seconds before the transaction expires.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ createTransaction(params?: { ttl?: number }): Promise;
+ /**
+ * Create a new transaction.
+ *
+ * @param {number} ttl - Seconds before the transaction expires.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ createTransaction(ttl?: number): Promise;
+ createTransaction(
+ paramsOrFirst?: { ttl?: number } | number
+ ): Promise {
+ let params: { ttl?: number };
+
+ if (!paramsOrFirst || (paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
+ params = (paramsOrFirst || {}) as { ttl?: number };
+ } else {
+ params = {
+ ttl: paramsOrFirst as number
+ };
+ }
+
+ const ttl = params.ttl;
+
+
+ const apiPath = '/databases/transactions';
+ const payload: Payload = {};
+ if (typeof ttl !== 'undefined') {
+ payload['ttl'] = ttl;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'content-type': 'application/json',
+ }
+
+ return this.client.call(
+ 'post',
+ uri,
+ apiHeaders,
+ payload
+ );
+ }
+
+ /**
+ * Get a transaction by its unique ID.
+ *
+ * @param {string} params.transactionId - Transaction ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ getTransaction(params: { transactionId: string }): Promise;
+ /**
+ * Get a transaction by its unique ID.
+ *
+ * @param {string} transactionId - Transaction ID.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ getTransaction(transactionId: string): Promise;
+ getTransaction(
+ paramsOrFirst: { transactionId: string } | string
+ ): Promise {
+ let params: { transactionId: string };
+
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
+ params = (paramsOrFirst || {}) as { transactionId: string };
+ } else {
+ params = {
+ transactionId: paramsOrFirst as string
+ };
+ }
+
+ const transactionId = params.transactionId;
+
+ if (typeof transactionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "transactionId"');
+ }
+
+ const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', transactionId);
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ }
+
+ return this.client.call(
+ 'get',
+ uri,
+ apiHeaders,
+ payload
+ );
+ }
+
+ /**
+ * Update a transaction, to either commit or roll back its operations.
+ *
+ * @param {string} params.transactionId - Transaction ID.
+ * @param {boolean} params.commit - Commit transaction?
+ * @param {boolean} params.rollback - Rollback transaction?
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ updateTransaction(params: { transactionId: string, commit?: boolean, rollback?: boolean }): Promise;
+ /**
+ * Update a transaction, to either commit or roll back its operations.
+ *
+ * @param {string} transactionId - Transaction ID.
+ * @param {boolean} commit - Commit transaction?
+ * @param {boolean} rollback - Rollback transaction?
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ updateTransaction(transactionId: string, commit?: boolean, rollback?: boolean): Promise;
+ updateTransaction(
+ paramsOrFirst: { transactionId: string, commit?: boolean, rollback?: boolean } | string,
+ ...rest: [(boolean)?, (boolean)?]
+ ): Promise {
+ let params: { transactionId: string, commit?: boolean, rollback?: boolean };
+
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
+ params = (paramsOrFirst || {}) as { transactionId: string, commit?: boolean, rollback?: boolean };
+ } else {
+ params = {
+ transactionId: paramsOrFirst as string,
+ commit: rest[0] as boolean,
+ rollback: rest[1] as boolean
+ };
+ }
+
+ const transactionId = params.transactionId;
+ const commit = params.commit;
+ const rollback = params.rollback;
+
+ if (typeof transactionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "transactionId"');
+ }
+
+ const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', transactionId);
+ const payload: Payload = {};
+ if (typeof commit !== 'undefined') {
+ payload['commit'] = commit;
+ }
+ if (typeof rollback !== 'undefined') {
+ payload['rollback'] = rollback;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'content-type': 'application/json',
+ }
+
+ return this.client.call(
+ 'patch',
+ uri,
+ apiHeaders,
+ payload
+ );
+ }
+
+ /**
+ * Delete a transaction by its unique ID.
+ *
+ * @param {string} params.transactionId - Transaction ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ */
+ deleteTransaction(params: { transactionId: string }): Promise<{}>;
+ /**
+ * Delete a transaction by its unique ID.
+ *
+ * @param {string} transactionId - Transaction ID.
+ * @throws {AppwriteException}
+ * @returns {Promise<{}>}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ deleteTransaction(transactionId: string): Promise<{}>;
+ deleteTransaction(
+ paramsOrFirst: { transactionId: string } | string
+ ): Promise<{}> {
+ let params: { transactionId: string };
+
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
+ params = (paramsOrFirst || {}) as { transactionId: string };
+ } else {
+ params = {
+ transactionId: paramsOrFirst as string
+ };
+ }
+
+ const transactionId = params.transactionId;
+
+ if (typeof transactionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "transactionId"');
+ }
+
+ const apiPath = '/databases/transactions/{transactionId}'.replace('{transactionId}', transactionId);
+ const payload: Payload = {};
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'content-type': 'application/json',
+ }
+
+ return this.client.call(
+ 'delete',
+ uri,
+ apiHeaders,
+ payload
+ );
+ }
+
+ /**
+ * Create multiple operations in a single transaction.
+ *
+ * @param {string} params.transactionId - Transaction ID.
+ * @param {object[]} params.operations - Array of staged operations.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ */
+ createOperations(params: { transactionId: string, operations?: object[] }): Promise;
+ /**
+ * Create multiple operations in a single transaction.
+ *
+ * @param {string} transactionId - Transaction ID.
+ * @param {object[]} operations - Array of staged operations.
+ * @throws {AppwriteException}
+ * @returns {Promise}
+ * @deprecated Use the object parameter style method for a better developer experience.
+ */
+ createOperations(transactionId: string, operations?: object[]): Promise;
+ createOperations(
+ paramsOrFirst: { transactionId: string, operations?: object[] } | string,
+ ...rest: [(object[])?]
+ ): Promise {
+ let params: { transactionId: string, operations?: object[] };
+
+ if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
+ params = (paramsOrFirst || {}) as { transactionId: string, operations?: object[] };
+ } else {
+ params = {
+ transactionId: paramsOrFirst as string,
+ operations: rest[0] as object[]
+ };
+ }
+
+ const transactionId = params.transactionId;
+ const operations = params.operations;
+
+ if (typeof transactionId === 'undefined') {
+ throw new AppwriteException('Missing required parameter: "transactionId"');
+ }
+
+ const apiPath = '/databases/transactions/{transactionId}/operations'.replace('{transactionId}', transactionId);
+ const payload: Payload = {};
+ if (typeof operations !== 'undefined') {
+ payload['operations'] = operations;
+ }
+ const uri = new URL(this.client.config.endpoint + apiPath);
+
+ const apiHeaders: { [header: string]: string } = {
+ 'content-type': 'application/json',
+ }
+
+ return this.client.call(
+ 'post',
+ uri,
+ apiHeaders,
+ payload
+ );
+ }
+
/**
* Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
*
* @param {string} params.databaseId - Database ID.
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
* @param {string[]} params.queries - 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.
+ * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction.
* @throws {AppwriteException}
* @returns {Promise>}
* @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.listRows` instead.
*/
- listDocuments(params: { databaseId: string, collectionId: string, queries?: string[] }): Promise>;
+ listDocuments(params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string }): Promise>;
/**
* Get a list of all the user's documents in a given collection. You can use the query params to filter your results.
*
* @param {string} databaseId - Database ID.
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
* @param {string[]} queries - 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.
+ * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction.
* @throws {AppwriteException}
* @returns {Promise>}
* @deprecated Use the object parameter style method for a better developer experience.
*/
- listDocuments(databaseId: string, collectionId: string, queries?: string[]): Promise>;
+ listDocuments(databaseId: string, collectionId: string, queries?: string[], transactionId?: string): Promise>;
listDocuments(
- paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[] } | string,
- ...rest: [(string)?, (string[])?]
+ paramsOrFirst: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string } | string,
+ ...rest: [(string)?, (string[])?, (string)?]
): Promise> {
- let params: { databaseId: string, collectionId: string, queries?: string[] };
+ let params: { databaseId: string, collectionId: string, queries?: string[], transactionId?: string };
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
- params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[] };
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, queries?: string[], transactionId?: string };
} else {
params = {
databaseId: paramsOrFirst as string,
collectionId: rest[0] as string,
- queries: rest[1] as string[]
+ queries: rest[1] as string[],
+ transactionId: rest[2] as string
};
}
const databaseId = params.databaseId;
const collectionId = params.collectionId;
const queries = params.queries;
+ const transactionId = params.transactionId;
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -64,6 +401,9 @@ export class Databases {
if (typeof queries !== 'undefined') {
payload['queries'] = queries;
}
+ if (typeof transactionId !== 'undefined') {
+ payload['transactionId'] = transactionId;
+ }
const uri = new URL(this.client.config.endpoint + apiPath);
const apiHeaders: { [header: string]: string } = {
@@ -85,11 +425,12 @@ export class Databases {
* @param {string} params.documentId - 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.
* @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} params.data - Document data as JSON object.
* @param {string[]} params.permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
+ * @param {string} params.transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise}
* @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.createRow` instead.
*/
- createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] }): Promise;
+ createDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string }): Promise;
/**
* Create a new Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
*
@@ -98,26 +439,28 @@ export class Databases {
* @param {string} documentId - 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.
* @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit} data - Document data as JSON object.
* @param {string[]} permissions - An array of permissions strings. By default, only the current user is granted all permissions. [Learn more about permissions](https://appwrite.io/docs/permissions).
+ * @param {string} transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise}
* @deprecated Use the object parameter style method for a better developer experience.
*/
- createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[]): Promise;
+ createDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string): Promise;
createDocument(
- paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] } | string,
- ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?]
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string } | string,
+ ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit)?, (string[])?, (string)?]
): Promise {
- let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] };
+ let params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string };
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
- params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[] };
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit, permissions?: string[], transactionId?: string };
} else {
params = {
databaseId: paramsOrFirst as string,
collectionId: rest[0] as string,
documentId: rest[1] as string,
data: rest[2] as Document extends Models.DefaultDocument ? Partial & Record : Partial & Omit,
- permissions: rest[3] as string[]
+ permissions: rest[3] as string[],
+ transactionId: rest[4] as string
};
}
@@ -126,6 +469,7 @@ export class Databases {
const documentId = params.documentId;
const data = params.data;
const permissions = params.permissions;
+ const transactionId = params.transactionId;
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -151,6 +495,9 @@ export class Databases {
if (typeof permissions !== 'undefined') {
payload['permissions'] = permissions;
}
+ if (typeof transactionId !== 'undefined') {
+ payload['transactionId'] = transactionId;
+ }
const uri = new URL(this.client.config.endpoint + apiPath);
const apiHeaders: { [header: string]: string } = {
@@ -172,11 +519,12 @@ export class Databases {
* @param {string} params.collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
* @param {string} params.documentId - Document ID.
* @param {string[]} params.queries - 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.
+ * @param {string} params.transactionId - Transaction ID to read uncommitted changes within the transaction.
* @throws {AppwriteException}
* @returns {Promise}
* @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.getRow` instead.
*/
- getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] }): Promise;
+ getDocument(params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string }): Promise;
/**
* Get a document by its unique ID. This endpoint response returns a JSON object with the document data.
*
@@ -184,25 +532,27 @@ export class Databases {
* @param {string} collectionId - Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).
* @param {string} documentId - Document ID.
* @param {string[]} queries - 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.
+ * @param {string} transactionId - Transaction ID to read uncommitted changes within the transaction.
* @throws {AppwriteException}
* @returns {Promise}
* @deprecated Use the object parameter style method for a better developer experience.
*/
- getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[]): Promise;
+ getDocument(databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string): Promise;
getDocument(
- paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[] } | string,
- ...rest: [(string)?, (string)?, (string[])?]
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string } | string,
+ ...rest: [(string)?, (string)?, (string[])?, (string)?]
): Promise {
- let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[] };
+ let params: { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string };
if ((paramsOrFirst && typeof paramsOrFirst === 'object' && !Array.isArray(paramsOrFirst))) {
- params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[] };
+ params = (paramsOrFirst || {}) as { databaseId: string, collectionId: string, documentId: string, queries?: string[], transactionId?: string };
} else {
params = {
databaseId: paramsOrFirst as string,
collectionId: rest[0] as string,
documentId: rest[1] as string,
- queries: rest[2] as string[]
+ queries: rest[2] as string[],
+ transactionId: rest[3] as string
};
}
@@ -210,6 +560,7 @@ export class Databases {
const collectionId = params.collectionId;
const documentId = params.documentId;
const queries = params.queries;
+ const transactionId = params.transactionId;
if (typeof databaseId === 'undefined') {
throw new AppwriteException('Missing required parameter: "databaseId"');
@@ -226,6 +577,9 @@ export class Databases {
if (typeof queries !== 'undefined') {
payload['queries'] = queries;
}
+ if (typeof transactionId !== 'undefined') {
+ payload['transactionId'] = transactionId;
+ }
const uri = new URL(this.client.config.endpoint + apiPath);
const apiHeaders: { [header: string]: string } = {
@@ -247,11 +601,12 @@ export class Databases {
* @param {string} params.documentId - Document ID.
* @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} params.data - Document data as JSON object. Include all required attributes of the document to be created or updated.
* @param {string[]} params.permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
+ * @param {string} params.transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise}
* @deprecated This API has been deprecated since 1.8.0. Please use `TablesDB.upsertRow` instead.
*/
- upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[] }): Promise;
+ upsertDocument(params: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string }): Promise;
/**
* Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
*
@@ -260,26 +615,28 @@ export class Databases {
* @param {string} documentId - Document ID.
* @param {Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>} data - Document data as JSON object. Include all required attributes of the document to be created or updated.
* @param {string[]} permissions - An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions).
+ * @param {string} transactionId - Transaction ID for staging the operation.
* @throws {AppwriteException}
* @returns {Promise}
* @deprecated Use the object parameter style method for a better developer experience.
*/
- upsertDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[]): Promise;
+ upsertDocument(databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string): Promise;
upsertDocument(
- paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[] } | string,
- ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>)?, (string[])?]
+ paramsOrFirst: { databaseId: string, collectionId: string, documentId: string, data: Document extends Models.DefaultDocument ? Partial & Record : Partial & Partial>, permissions?: string[], transactionId?: string } | string,
+ ...rest: [(string)?, (string)?, (Document extends Models.DefaultDocument ? Partial & Record