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

## 21.2.0

* Add transaction support for Databases and TablesDB

## 21.1.0

* Deprecate `createVerification` method in `Account` service
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <body> tag, but before you use any Appwrite services:

```html
<script src="https://cdn.jsdelivr.net/npm/appwrite@21.1.0"></script>
<script src="https://cdn.jsdelivr.net/npm/appwrite@21.2.0"></script>
```


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 @@ -17,7 +17,8 @@ const result = await databases.createDocument({
"age": 30,
"isAdmin": false
},
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Comment on lines +20 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Correct the permissions string literal.

["read("any")"] breaks due to unescaped quotes. Update the example so it’s valid JavaScript.

-    permissions: ["read("any")"], // optional
+    permissions: ['read("any")'], // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
permissions: ['read("any")'], // optional
transactionId: '<TRANSACTION_ID>' // optional
🤖 Prompt for AI Agents
In docs/examples/databases/create-document.md around lines 20 to 21, the
permissions example uses ["read("any")"] which contains unescaped quotes and is
invalid JavaScript; replace that entry with a properly quoted string (for
example use single quotes around the outer string and keep the inner double
quotes, or escape the inner quotes) so the permissions array contains a valid
string literal like read("any") without syntax errors.

});

console.log(result);
24 changes: 24 additions & 0 deletions docs/examples/databases/create-operations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.createOperations({
transactionId: '<TRANSACTION_ID>',
operations: [
{
"action": "create",
"databaseId": "<DATABASE_ID>",
"collectionId": "<COLLECTION_ID>",
"documentId": "<DOCUMENT_ID>",
"data": {
"name": "Walter O'Brien"
}
}
] // optional
});

console.log(result);
13 changes: 13 additions & 0 deletions docs/examples/databases/create-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.createTransaction({
ttl: 60 // optional
});

console.log(result);
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 @@ -12,7 +12,8 @@ const result = await databases.decrementDocumentAttribute({
documentId: '<DOCUMENT_ID>',
attribute: '',
value: null, // optional
min: null // optional
min: null, // optional
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/databases/delete-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const databases = new Databases(client);
const result = await databases.deleteDocument({
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>'
documentId: '<DOCUMENT_ID>',
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
13 changes: 13 additions & 0 deletions docs/examples/databases/delete-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.deleteTransaction({
transactionId: '<TRANSACTION_ID>'
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/databases/get-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const result = await databases.getDocument({
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
queries: [] // optional
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
13 changes: 13 additions & 0 deletions docs/examples/databases/get-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.getTransaction({
transactionId: '<TRANSACTION_ID>'
});

console.log(result);
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 @@ -12,7 +12,8 @@ const result = await databases.incrementDocumentAttribute({
documentId: '<DOCUMENT_ID>',
attribute: '',
value: null, // optional
max: null // optional
max: null, // optional
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/databases/list-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const databases = new Databases(client);
const result = await databases.listDocuments({
databaseId: '<DATABASE_ID>',
collectionId: '<COLLECTION_ID>',
queries: [] // optional
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
13 changes: 13 additions & 0 deletions docs/examples/databases/list-transactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.listTransactions({
queries: [] // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/databases/update-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const result = await databases.updateDocument({
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
data: {}, // optional
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Comment on lines +14 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Use valid quoting for the permissions entry.

The example currently reads ["read("any")"], which is invalid. Switch the outer quotes or escape the inner quotes.

-    permissions: ["read("any")"], // optional
+    permissions: ['read("any")'], // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
permissions: ['read("any")'], // optional
transactionId: '<TRANSACTION_ID>' // optional
🤖 Prompt for AI Agents
In docs/examples/databases/update-document.md around lines 14 to 15, the
permissions entry uses invalid nesting of double quotes (["read("any")"]) — fix
by using valid quoting or escaping so the permission string is syntactically
correct, e.g., switch outer quotes to single quotes or escape inner quotes so
the permissions array contains a single valid string like 'read("any")' or
"read(\"any\")".

});

console.log(result);
15 changes: 15 additions & 0 deletions docs/examples/databases/update-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Client, Databases } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const databases = new Databases(client);

const result = await databases.updateTransaction({
transactionId: '<TRANSACTION_ID>',
commit: false, // optional
rollback: false // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/databases/upsert-document.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const result = await databases.upsertDocument({
collectionId: '<COLLECTION_ID>',
documentId: '<DOCUMENT_ID>',
data: {},
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Comment on lines +14 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Repair the permissions string literal.

["read("any")"] cannot be parsed. Please adopt single quotes externally or escape appropriately.

-    permissions: ["read("any")"], // optional
+    permissions: ['read("any")'], // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
permissions: ['read("any")'], // optional
transactionId: '<TRANSACTION_ID>' // optional
🤖 Prompt for AI Agents
In docs/examples/databases/upsert-document.md around lines 14 to 15, the
permissions string literal is invalid: replace the current ["read("any")"] with
a validly quoted string such as ["read('any')"] (or alternatively use
single-quoted outer strings with double quotes inside: ['read("any")']), or
escape the inner quotes so the JSON/JS parser can parse it.

});

console.log(result);
24 changes: 24 additions & 0 deletions docs/examples/tablesdb/create-operations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Client, TablesDB } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const tablesDB = new TablesDB(client);

const result = await tablesDB.createOperations({
transactionId: '<TRANSACTION_ID>',
operations: [
{
"action": "create",
"databaseId": "<DATABASE_ID>",
"tableId": "<TABLE_ID>",
"rowId": "<ROW_ID>",
"data": {
"name": "Walter O'Brien"
}
}
] // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/create-row.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ const result = await tablesDB.createRow({
"age": 30,
"isAdmin": false
},
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Comment on lines +20 to +21
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix the permissions string literal.

"read("any")" is invalid JS/TS because the inner quotes terminate the string. The example will throw before it ever reaches the new transactionId field—escape the inner quotes or switch to single quotes. e.g. permissions: ['read("any")'],.

🤖 Prompt for AI Agents
In docs/examples/tablesdb/create-row.md around lines 20 to 21, the permissions
string literal uses double quotes inside double quotes ("read("any")") which is
invalid JS/TS and will throw; fix by either switching to single quotes for the
outer string (e.g. permissions: ['read("any")']) or escaping the inner quotes
(e.g. permissions: ["read(\"any\")"]) so the example is valid and the subsequent
transactionId field can be reached.

});

console.log(result);
13 changes: 13 additions & 0 deletions docs/examples/tablesdb/create-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client, TablesDB } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const tablesDB = new TablesDB(client);

const result = await tablesDB.createTransaction({
ttl: 60 // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/decrement-row-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const result = await tablesDB.decrementRowColumn({
rowId: '<ROW_ID>',
column: '',
value: null, // optional
min: null // optional
min: null, // optional
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/delete-row.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client);
const result = await tablesDB.deleteRow({
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
rowId: '<ROW_ID>'
rowId: '<ROW_ID>',
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
13 changes: 13 additions & 0 deletions docs/examples/tablesdb/delete-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client, TablesDB } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const tablesDB = new TablesDB(client);

const result = await tablesDB.deleteTransaction({
transactionId: '<TRANSACTION_ID>'
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/get-row.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const result = await tablesDB.getRow({
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
rowId: '<ROW_ID>',
queries: [] // optional
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
Comment on lines +13 to +14
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Remove unsupported queries option from getRow example.

TablesDB.getRow only accepts databaseId, tableId, rowId, and optional transactionId. It does not accept a queries array, so copying this example will throw a validation error. Please drop the queries line.

🤖 Prompt for AI Agents
In docs/examples/tablesdb/get-row.md around lines 13 to 14, the example wrongly
includes a queries: [] option which TablesDB.getRow does not support; remove the
entire queries line so the example only provides databaseId, tableId, rowId, and
the optional transactionId, ensuring the example matches the method signature
and will not trigger validation errors.

});

console.log(result);
13 changes: 13 additions & 0 deletions docs/examples/tablesdb/get-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client, TablesDB } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const tablesDB = new TablesDB(client);

const result = await tablesDB.getTransaction({
transactionId: '<TRANSACTION_ID>'
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/increment-row-column.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const result = await tablesDB.incrementRowColumn({
rowId: '<ROW_ID>',
column: '',
value: null, // optional
max: null // optional
max: null, // optional
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/list-rows.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const tablesDB = new TablesDB(client);
const result = await tablesDB.listRows({
databaseId: '<DATABASE_ID>',
tableId: '<TABLE_ID>',
queries: [] // optional
queries: [], // optional
transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
13 changes: 13 additions & 0 deletions docs/examples/tablesdb/list-transactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Client, TablesDB } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const tablesDB = new TablesDB(client);

const result = await tablesDB.listTransactions({
queries: [] // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/update-row.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const result = await tablesDB.updateRow({
tableId: '<TABLE_ID>',
rowId: '<ROW_ID>',
data: {}, // optional
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
Comment on lines +14 to +15
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix invalid string quoting in permissions example.

["read("any")"] is not valid JavaScript because the inner quotes terminate the string early, making this snippet unusable as-is. Please wrap the outer string in single quotes (or escape the inner quotes) so developers can copy-paste without hitting a syntax error.

-    permissions: ["read("any")"], // optional
+    permissions: ['read("any")'], // optional
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
permissions: ["read("any")"], // optional
transactionId: '<TRANSACTION_ID>' // optional
permissions: ['read("any")'], // optional
transactionId: '<TRANSACTION_ID>' // optional
🤖 Prompt for AI Agents
In docs/examples/tablesdb/update-row.md around lines 14 to 15, the permissions
example uses invalid double-quote nesting: ["read("any")"] which breaks
JavaScript parsing; update the snippet to either wrap the outer string in single
quotes (e.g., ['read("any")']) or escape the inner quotes (e.g.,
["read(\"any\")"]) so the permissions array is valid and copy-pastable; ensure
the chosen style matches surrounding examples for consistency.

});

console.log(result);
15 changes: 15 additions & 0 deletions docs/examples/tablesdb/update-transaction.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Client, TablesDB } from "appwrite";

const client = new Client()
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<YOUR_PROJECT_ID>'); // Your project ID

const tablesDB = new TablesDB(client);

const result = await tablesDB.updateTransaction({
transactionId: '<TRANSACTION_ID>',
commit: false, // optional
rollback: false // optional
});

console.log(result);
3 changes: 2 additions & 1 deletion docs/examples/tablesdb/upsert-row.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const result = await tablesDB.upsertRow({
tableId: '<TABLE_ID>',
rowId: '<ROW_ID>',
data: {}, // optional
permissions: ["read("any")"] // optional
permissions: ["read("any")"], // optional
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Fix malformed string literal in permissions.

["read("any")"] is invalid JavaScript because the inner quotes terminate the string. Restore the previous escaping (['read("any")'] or "read(\"any\")") so the snippet runs as-is.

🤖 Prompt for AI Agents
In docs/examples/tablesdb/upsert-row.md around line 14, the permissions array
contains a malformed string literal permissions: ["read("any")"] which breaks JS
parsing; change it to use a string that preserves the inner quotes, e.g. use
single outer quotes with double inner quotes ['read("any")'] or escape the inner
quotes with backslashes "read(\"any\")", so the snippet is valid and runs as-is.

transactionId: '<TRANSACTION_ID>' // optional
});

console.log(result);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

Expand Down
Loading