Skip to content

Commit cc559f0

Browse files
committed
Add txn support
1 parent 8a5d716 commit cc559f0

35 files changed

+1155
-135
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { Client, Account } from "appwrite";
3333
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:
3434

3535
```html
36-
<script src="https://cdn.jsdelivr.net/npm/appwrite@20.0.0"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/appwrite@20.1.0-rc.1"></script>
3737
```
3838

3939

docs/examples/databases/create-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const result = await databases.createDocument({
1717
"age": 30,
1818
"isAdmin": false
1919
},
20-
permissions: ["read("any")"] // optional
20+
permissions: ["read("any")"], // optional
21+
transactionId: '<TRANSACTION_ID>' // optional
2122
});
2223

2324
console.log(result);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Client, Databases } from "appwrite";
2+
3+
const client = new Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.createOperations({
10+
transactionId: '<TRANSACTION_ID>',
11+
operations: [
12+
{
13+
"action": "create",
14+
"databaseId": "<DATABASE_ID>",
15+
"collectionId": "<COLLECTION_ID>",
16+
"documentId": "<DOCUMENT_ID>",
17+
"data": {
18+
"name": "Walter O'Brien"
19+
}
20+
}
21+
] // optional
22+
});
23+
24+
console.log(result);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Client, Databases } from "appwrite";
2+
3+
const client = new Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.createTransaction({
10+
ttl: 60 // optional
11+
});
12+
13+
console.log(result);

docs/examples/databases/decrement-document-attribute.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const result = await databases.decrementDocumentAttribute({
1212
documentId: '<DOCUMENT_ID>',
1313
attribute: '',
1414
value: null, // optional
15-
min: null // optional
15+
min: null, // optional
16+
transactionId: '<TRANSACTION_ID>' // optional
1617
});
1718

1819
console.log(result);

docs/examples/databases/delete-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const databases = new Databases(client);
99
const result = await databases.deleteDocument({
1010
databaseId: '<DATABASE_ID>',
1111
collectionId: '<COLLECTION_ID>',
12-
documentId: '<DOCUMENT_ID>'
12+
documentId: '<DOCUMENT_ID>',
13+
transactionId: '<TRANSACTION_ID>' // optional
1314
});
1415

1516
console.log(result);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Client, Databases } from "appwrite";
2+
3+
const client = new Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.deleteTransaction({
10+
transactionId: '<TRANSACTION_ID>'
11+
});
12+
13+
console.log(result);

docs/examples/databases/get-document.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const result = await databases.getDocument({
1010
databaseId: '<DATABASE_ID>',
1111
collectionId: '<COLLECTION_ID>',
1212
documentId: '<DOCUMENT_ID>',
13-
queries: [] // optional
13+
queries: [], // optional
14+
transactionId: '<TRANSACTION_ID>' // optional
1415
});
1516

1617
console.log(result);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Client, Databases } from "appwrite";
2+
3+
const client = new Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.getTransaction({
10+
transactionId: '<TRANSACTION_ID>'
11+
});
12+
13+
console.log(result);

docs/examples/databases/increment-document-attribute.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const result = await databases.incrementDocumentAttribute({
1212
documentId: '<DOCUMENT_ID>',
1313
attribute: '',
1414
value: null, // optional
15-
max: null // optional
15+
max: null, // optional
16+
transactionId: '<TRANSACTION_ID>' // optional
1617
});
1718

1819
console.log(result);

0 commit comments

Comments
 (0)