Skip to content

Commit edde3af

Browse files
committed
Add transactions
1 parent 5a6b3c8 commit edde3af

Some content is hidden

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

63 files changed

+1107
-3
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+
## 11.2.0
4+
5+
* Add transaction support for Databases and TablesDB
6+
37
## 11.1.0
48

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

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ repositories {
3838
Next, add the dependency to your project's `build.gradle(.kts)` file:
3939

4040
```groovy
41-
implementation("io.appwrite:sdk-for-android:11.1.0")
41+
implementation("io.appwrite:sdk-for-android:11.2.0")
4242
```
4343

4444
### Maven
@@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file:
4949
<dependency>
5050
<groupId>io.appwrite</groupId>
5151
<artifactId>sdk-for-android</artifactId>
52-
<version>11.1.0</version>
52+
<version>11.2.0</version>
5353
</dependency>
5454
</dependencies>
5555
```

docs/examples/java/databases/create-document.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ databases.createDocument(
2020
"isAdmin" to false
2121
), // data
2222
listOf("read("any")"), // permissions (optional)
23+
"<TRANSACTION_ID>", // transactionId (optional)
2324
new CoroutineCallback<>((result, error) -> {
2425
if (error != null) {
2526
error.printStackTrace();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
8+
9+
Databases databases = new Databases(client);
10+
11+
databases.createOperations(
12+
"<TRANSACTION_ID>", // transactionId
13+
listOf(
14+
{
15+
"action": "create",
16+
"databaseId": "<DATABASE_ID>",
17+
"collectionId": "<COLLECTION_ID>",
18+
"documentId": "<DOCUMENT_ID>",
19+
"data": {
20+
"name": "Walter O'Brien"
21+
}
22+
}
23+
), // operations (optional)
24+
new CoroutineCallback<>((result, error) -> {
25+
if (error != null) {
26+
error.printStackTrace();
27+
return;
28+
}
29+
30+
Log.d("Appwrite", result.toString());
31+
})
32+
);
33+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
8+
9+
Databases databases = new Databases(client);
10+
11+
databases.createTransaction(
12+
60, // ttl (optional)
13+
new CoroutineCallback<>((result, error) -> {
14+
if (error != null) {
15+
error.printStackTrace();
16+
return;
17+
}
18+
19+
Log.d("Appwrite", result.toString());
20+
})
21+
);
22+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ databases.decrementDocumentAttribute(
1515
"", // attribute
1616
0, // value (optional)
1717
0, // min (optional)
18+
"<TRANSACTION_ID>", // transactionId (optional)
1819
new CoroutineCallback<>((result, error) -> {
1920
if (error != null) {
2021
error.printStackTrace();

docs/examples/java/databases/delete-document.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ databases.deleteDocument(
1212
"<DATABASE_ID>", // databaseId
1313
"<COLLECTION_ID>", // collectionId
1414
"<DOCUMENT_ID>", // documentId
15+
"<TRANSACTION_ID>", // transactionId (optional)
1516
new CoroutineCallback<>((result, error) -> {
1617
if (error != null) {
1718
error.printStackTrace();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
8+
9+
Databases databases = new Databases(client);
10+
11+
databases.deleteTransaction(
12+
"<TRANSACTION_ID>", // transactionId
13+
new CoroutineCallback<>((result, error) -> {
14+
if (error != null) {
15+
error.printStackTrace();
16+
return;
17+
}
18+
19+
Log.d("Appwrite", result.toString());
20+
})
21+
);
22+

docs/examples/java/databases/get-document.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ databases.getDocument(
1313
"<COLLECTION_ID>", // collectionId
1414
"<DOCUMENT_ID>", // documentId
1515
listOf(), // queries (optional)
16+
"<TRANSACTION_ID>", // transactionId (optional)
1617
new CoroutineCallback<>((result, error) -> {
1718
if (error != null) {
1819
error.printStackTrace();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
8+
9+
Databases databases = new Databases(client);
10+
11+
databases.getTransaction(
12+
"<TRANSACTION_ID>", // transactionId
13+
new CoroutineCallback<>((result, error) -> {
14+
if (error != null) {
15+
error.printStackTrace();
16+
return;
17+
}
18+
19+
Log.d("Appwrite", result.toString());
20+
})
21+
);
22+

0 commit comments

Comments
 (0)