Skip to content

Commit 71f8567

Browse files
authored
Merge pull request #126 from appwrite/dev
feat: Node.js SDK update for version 20.2.0
2 parents 7864c83 + cbd9e06 commit 71f8567

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1275
-199
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 20.2.0
4+
5+
* Add transaction support for Databases and TablesDB
6+
37
## 20.1.0
48

59
* Deprecate `createVerification` method in `Account` service

docs/examples/databases/create-document.md

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

docs/examples/databases/create-documents.md

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

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

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

docs/examples/databases/delete-document.md

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

docs/examples/databases/delete-documents.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ const databases = new sdk.Databases(client);
1010
const result = await databases.deleteDocuments({
1111
databaseId: '<DATABASE_ID>',
1212
collectionId: '<COLLECTION_ID>',
13-
queries: [] // optional
13+
queries: [], // optional
14+
transactionId: '<TRANSACTION_ID>' // optional
1415
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const sdk = require('node-appwrite');
2+
3+
const client = new sdk.Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setProject('<YOUR_PROJECT_ID>') // Your project ID
6+
.setKey('<YOUR_API_KEY>'); // Your secret API key
7+
8+
const databases = new sdk.Databases(client);
9+
10+
const result = await databases.deleteTransaction({
11+
transactionId: '<TRANSACTION_ID>'
12+
});

docs/examples/databases/get-document.md

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

0 commit comments

Comments
 (0)