diff --git a/CHANGELOG.md b/CHANGELOG.md index b6b9e40..559b61f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 11.2.0 + +* Add transaction support for Databases and TablesDB + ## 11.1.0 * Deprecate `createVerification` method in `Account` service diff --git a/README.md b/README.md index bd59ff0..79b38e4 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ repositories { Next, add the dependency to your project's `build.gradle(.kts)` file: ```groovy -implementation("io.appwrite:sdk-for-android:11.1.0") +implementation("io.appwrite:sdk-for-android:11.2.0") ``` ### Maven @@ -49,7 +49,7 @@ Add this to your project's `pom.xml` file: io.appwrite sdk-for-android - 11.1.0 + 11.2.0 ``` diff --git a/docs/examples/java/databases/create-document.md b/docs/examples/java/databases/create-document.md index bd0b57a..694d99a 100644 --- a/docs/examples/java/databases/create-document.md +++ b/docs/examples/java/databases/create-document.md @@ -20,6 +20,7 @@ databases.createDocument( "isAdmin" to false ), // data listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/create-operations.md b/docs/examples/java/databases/create-operations.md new file mode 100644 index 0000000..def58af --- /dev/null +++ b/docs/examples/java/databases/create-operations.md @@ -0,0 +1,33 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.createOperations( + "", // transactionId + listOf( + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ), // operations (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/create-transaction.md b/docs/examples/java/databases/create-transaction.md new file mode 100644 index 0000000..871d190 --- /dev/null +++ b/docs/examples/java/databases/create-transaction.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.createTransaction( + 60, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/decrement-document-attribute.md b/docs/examples/java/databases/decrement-document-attribute.md index de6a4ab..8669494 100644 --- a/docs/examples/java/databases/decrement-document-attribute.md +++ b/docs/examples/java/databases/decrement-document-attribute.md @@ -15,6 +15,7 @@ databases.decrementDocumentAttribute( "", // attribute 0, // value (optional) 0, // min (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/delete-document.md b/docs/examples/java/databases/delete-document.md index 5288e53..2795670 100644 --- a/docs/examples/java/databases/delete-document.md +++ b/docs/examples/java/databases/delete-document.md @@ -12,6 +12,7 @@ databases.deleteDocument( "", // databaseId "", // collectionId "", // documentId + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/delete-transaction.md b/docs/examples/java/databases/delete-transaction.md new file mode 100644 index 0000000..ac1121e --- /dev/null +++ b/docs/examples/java/databases/delete-transaction.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.deleteTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/get-document.md b/docs/examples/java/databases/get-document.md index e7ae207..92d6b5e 100644 --- a/docs/examples/java/databases/get-document.md +++ b/docs/examples/java/databases/get-document.md @@ -13,6 +13,7 @@ databases.getDocument( "", // collectionId "", // documentId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/get-transaction.md b/docs/examples/java/databases/get-transaction.md new file mode 100644 index 0000000..5dee850 --- /dev/null +++ b/docs/examples/java/databases/get-transaction.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.getTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/increment-document-attribute.md b/docs/examples/java/databases/increment-document-attribute.md index 94ffa9d..5928b45 100644 --- a/docs/examples/java/databases/increment-document-attribute.md +++ b/docs/examples/java/databases/increment-document-attribute.md @@ -15,6 +15,7 @@ databases.incrementDocumentAttribute( "", // attribute 0, // value (optional) 0, // max (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/list-documents.md b/docs/examples/java/databases/list-documents.md index 606d677..7b2ba23 100644 --- a/docs/examples/java/databases/list-documents.md +++ b/docs/examples/java/databases/list-documents.md @@ -12,6 +12,7 @@ databases.listDocuments( "", // databaseId "", // collectionId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/list-transactions.md b/docs/examples/java/databases/list-transactions.md new file mode 100644 index 0000000..39f58f3 --- /dev/null +++ b/docs/examples/java/databases/list-transactions.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.listTransactions( + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/update-document.md b/docs/examples/java/databases/update-document.md index baa827c..a6103e4 100644 --- a/docs/examples/java/databases/update-document.md +++ b/docs/examples/java/databases/update-document.md @@ -14,6 +14,7 @@ databases.updateDocument( "", // documentId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/databases/update-transaction.md b/docs/examples/java/databases/update-transaction.md new file mode 100644 index 0000000..c5f586f --- /dev/null +++ b/docs/examples/java/databases/update-transaction.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.Databases; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +Databases databases = new Databases(client); + +databases.updateTransaction( + "", // transactionId + false, // commit (optional) + false, // rollback (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/databases/upsert-document.md b/docs/examples/java/databases/upsert-document.md index 868576b..52be46e 100644 --- a/docs/examples/java/databases/upsert-document.md +++ b/docs/examples/java/databases/upsert-document.md @@ -14,6 +14,7 @@ databases.upsertDocument( "", // documentId mapOf( "a" to "b" ), // data listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/create-operations.md b/docs/examples/java/tablesdb/create-operations.md new file mode 100644 index 0000000..7ca288c --- /dev/null +++ b/docs/examples/java/tablesdb/create-operations.md @@ -0,0 +1,33 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.createOperations( + "", // transactionId + listOf( + { + "action": "create", + "databaseId": "", + "tableId": "", + "rowId": "", + "data": { + "name": "Walter O'Brien" + } + } + ), // operations (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/create-row.md b/docs/examples/java/tablesdb/create-row.md index 8273573..92a9058 100644 --- a/docs/examples/java/tablesdb/create-row.md +++ b/docs/examples/java/tablesdb/create-row.md @@ -20,6 +20,7 @@ tablesDB.createRow( "isAdmin" to false ), // data listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/create-transaction.md b/docs/examples/java/tablesdb/create-transaction.md new file mode 100644 index 0000000..c232c56 --- /dev/null +++ b/docs/examples/java/tablesdb/create-transaction.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.createTransaction( + 60, // ttl (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/decrement-row-column.md b/docs/examples/java/tablesdb/decrement-row-column.md index 73f2128..2252564 100644 --- a/docs/examples/java/tablesdb/decrement-row-column.md +++ b/docs/examples/java/tablesdb/decrement-row-column.md @@ -15,6 +15,7 @@ tablesDB.decrementRowColumn( "", // column 0, // value (optional) 0, // min (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/delete-row.md b/docs/examples/java/tablesdb/delete-row.md index d4c351b..6680100 100644 --- a/docs/examples/java/tablesdb/delete-row.md +++ b/docs/examples/java/tablesdb/delete-row.md @@ -12,6 +12,7 @@ tablesDB.deleteRow( "", // databaseId "", // tableId "", // rowId + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/delete-transaction.md b/docs/examples/java/tablesdb/delete-transaction.md new file mode 100644 index 0000000..18cb235 --- /dev/null +++ b/docs/examples/java/tablesdb/delete-transaction.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.deleteTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/get-row.md b/docs/examples/java/tablesdb/get-row.md index 191fc89..45efc6b 100644 --- a/docs/examples/java/tablesdb/get-row.md +++ b/docs/examples/java/tablesdb/get-row.md @@ -13,6 +13,7 @@ tablesDB.getRow( "", // tableId "", // rowId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/get-transaction.md b/docs/examples/java/tablesdb/get-transaction.md new file mode 100644 index 0000000..fb51916 --- /dev/null +++ b/docs/examples/java/tablesdb/get-transaction.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.getTransaction( + "", // transactionId + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/increment-row-column.md b/docs/examples/java/tablesdb/increment-row-column.md index dc2120e..a1194a6 100644 --- a/docs/examples/java/tablesdb/increment-row-column.md +++ b/docs/examples/java/tablesdb/increment-row-column.md @@ -15,6 +15,7 @@ tablesDB.incrementRowColumn( "", // column 0, // value (optional) 0, // max (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/list-rows.md b/docs/examples/java/tablesdb/list-rows.md index dc50574..21f0005 100644 --- a/docs/examples/java/tablesdb/list-rows.md +++ b/docs/examples/java/tablesdb/list-rows.md @@ -12,6 +12,7 @@ tablesDB.listRows( "", // databaseId "", // tableId listOf(), // queries (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/list-transactions.md b/docs/examples/java/tablesdb/list-transactions.md new file mode 100644 index 0000000..c37ccf1 --- /dev/null +++ b/docs/examples/java/tablesdb/list-transactions.md @@ -0,0 +1,22 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.listTransactions( + listOf(), // queries (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/update-row.md b/docs/examples/java/tablesdb/update-row.md index 0f1fabc..cea7baa 100644 --- a/docs/examples/java/tablesdb/update-row.md +++ b/docs/examples/java/tablesdb/update-row.md @@ -14,6 +14,7 @@ tablesDB.updateRow( "", // rowId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/java/tablesdb/update-transaction.md b/docs/examples/java/tablesdb/update-transaction.md new file mode 100644 index 0000000..804b5d5 --- /dev/null +++ b/docs/examples/java/tablesdb/update-transaction.md @@ -0,0 +1,24 @@ +import io.appwrite.Client; +import io.appwrite.coroutines.CoroutineCallback; +import io.appwrite.services.TablesDB; + +Client client = new Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject(""); // Your project ID + +TablesDB tablesDB = new TablesDB(client); + +tablesDB.updateTransaction( + "", // transactionId + false, // commit (optional) + false, // rollback (optional) + new CoroutineCallback<>((result, error) -> { + if (error != null) { + error.printStackTrace(); + return; + } + + Log.d("Appwrite", result.toString()); + }) +); + diff --git a/docs/examples/java/tablesdb/upsert-row.md b/docs/examples/java/tablesdb/upsert-row.md index 22c0e94..9d6323f 100644 --- a/docs/examples/java/tablesdb/upsert-row.md +++ b/docs/examples/java/tablesdb/upsert-row.md @@ -14,6 +14,7 @@ tablesDB.upsertRow( "", // rowId mapOf( "a" to "b" ), // data (optional) listOf("read("any")"), // permissions (optional) + "", // transactionId (optional) new CoroutineCallback<>((result, error) -> { if (error != null) { error.printStackTrace(); diff --git a/docs/examples/kotlin/databases/create-document.md b/docs/examples/kotlin/databases/create-document.md index 7f0aaf8..7d4b04d 100644 --- a/docs/examples/kotlin/databases/create-document.md +++ b/docs/examples/kotlin/databases/create-document.md @@ -20,4 +20,5 @@ val result = databases.createDocument( "isAdmin" to false ), permissions = listOf("read("any")"), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/create-operations.md b/docs/examples/kotlin/databases/create-operations.md new file mode 100644 index 0000000..62c9335 --- /dev/null +++ b/docs/examples/kotlin/databases/create-operations.md @@ -0,0 +1,24 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.createOperations( + transactionId = "", + operations = listOf( + { + "action": "create", + "databaseId": "", + "collectionId": "", + "documentId": "", + "data": { + "name": "Walter O'Brien" + } + } + ), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/create-transaction.md b/docs/examples/kotlin/databases/create-transaction.md new file mode 100644 index 0000000..3b953c3 --- /dev/null +++ b/docs/examples/kotlin/databases/create-transaction.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.createTransaction( + ttl = 60, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/decrement-document-attribute.md b/docs/examples/kotlin/databases/decrement-document-attribute.md index c500fa8..84a4a0e 100644 --- a/docs/examples/kotlin/databases/decrement-document-attribute.md +++ b/docs/examples/kotlin/databases/decrement-document-attribute.md @@ -15,4 +15,5 @@ val result = databases.decrementDocumentAttribute( attribute = "", value = 0, // (optional) min = 0, // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/delete-document.md b/docs/examples/kotlin/databases/delete-document.md index 052bf97..242655e 100644 --- a/docs/examples/kotlin/databases/delete-document.md +++ b/docs/examples/kotlin/databases/delete-document.md @@ -12,4 +12,5 @@ val result = databases.deleteDocument( databaseId = "", collectionId = "", documentId = "", + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/delete-transaction.md b/docs/examples/kotlin/databases/delete-transaction.md new file mode 100644 index 0000000..bbce98c --- /dev/null +++ b/docs/examples/kotlin/databases/delete-transaction.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.deleteTransaction( + transactionId = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/get-document.md b/docs/examples/kotlin/databases/get-document.md index 157af2b..f21b6f3 100644 --- a/docs/examples/kotlin/databases/get-document.md +++ b/docs/examples/kotlin/databases/get-document.md @@ -13,4 +13,5 @@ val result = databases.getDocument( collectionId = "", documentId = "", queries = listOf(), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/get-transaction.md b/docs/examples/kotlin/databases/get-transaction.md new file mode 100644 index 0000000..0a1fda6 --- /dev/null +++ b/docs/examples/kotlin/databases/get-transaction.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.getTransaction( + transactionId = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/increment-document-attribute.md b/docs/examples/kotlin/databases/increment-document-attribute.md index 0ae6b02..ca32cfc 100644 --- a/docs/examples/kotlin/databases/increment-document-attribute.md +++ b/docs/examples/kotlin/databases/increment-document-attribute.md @@ -15,4 +15,5 @@ val result = databases.incrementDocumentAttribute( attribute = "", value = 0, // (optional) max = 0, // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-documents.md b/docs/examples/kotlin/databases/list-documents.md index 1cc785f..a2b6e0e 100644 --- a/docs/examples/kotlin/databases/list-documents.md +++ b/docs/examples/kotlin/databases/list-documents.md @@ -12,4 +12,5 @@ val result = databases.listDocuments( databaseId = "", collectionId = "", queries = listOf(), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/list-transactions.md b/docs/examples/kotlin/databases/list-transactions.md new file mode 100644 index 0000000..da5cd4b --- /dev/null +++ b/docs/examples/kotlin/databases/list-transactions.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.listTransactions( + queries = listOf(), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-document.md b/docs/examples/kotlin/databases/update-document.md index d61fdea..2cacce6 100644 --- a/docs/examples/kotlin/databases/update-document.md +++ b/docs/examples/kotlin/databases/update-document.md @@ -14,4 +14,5 @@ val result = databases.updateDocument( documentId = "", data = mapOf( "a" to "b" ), // (optional) permissions = listOf("read("any")"), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/update-transaction.md b/docs/examples/kotlin/databases/update-transaction.md new file mode 100644 index 0000000..c9d6a85 --- /dev/null +++ b/docs/examples/kotlin/databases/update-transaction.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.Databases + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val databases = Databases(client) + +val result = databases.updateTransaction( + transactionId = "", + commit = false, // (optional) + rollback = false, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/databases/upsert-document.md b/docs/examples/kotlin/databases/upsert-document.md index a31dfc8..e5ac437 100644 --- a/docs/examples/kotlin/databases/upsert-document.md +++ b/docs/examples/kotlin/databases/upsert-document.md @@ -14,4 +14,5 @@ val result = databases.upsertDocument( documentId = "", data = mapOf( "a" to "b" ), permissions = listOf("read("any")"), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/create-operations.md b/docs/examples/kotlin/tablesdb/create-operations.md new file mode 100644 index 0000000..3073a00 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/create-operations.md @@ -0,0 +1,24 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDB = TablesDB(client) + +val result = tablesDB.createOperations( + transactionId = "", + operations = listOf( + { + "action": "create", + "databaseId": "", + "tableId": "", + "rowId": "", + "data": { + "name": "Walter O'Brien" + } + } + ), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/create-row.md b/docs/examples/kotlin/tablesdb/create-row.md index eb44cc4..f5850b2 100644 --- a/docs/examples/kotlin/tablesdb/create-row.md +++ b/docs/examples/kotlin/tablesdb/create-row.md @@ -20,4 +20,5 @@ val result = tablesDB.createRow( "isAdmin" to false ), permissions = listOf("read("any")"), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/create-transaction.md b/docs/examples/kotlin/tablesdb/create-transaction.md new file mode 100644 index 0000000..b011fa0 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/create-transaction.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDB = TablesDB(client) + +val result = tablesDB.createTransaction( + ttl = 60, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/decrement-row-column.md b/docs/examples/kotlin/tablesdb/decrement-row-column.md index 645e9f4..1a89640 100644 --- a/docs/examples/kotlin/tablesdb/decrement-row-column.md +++ b/docs/examples/kotlin/tablesdb/decrement-row-column.md @@ -15,4 +15,5 @@ val result = tablesDB.decrementRowColumn( column = "", value = 0, // (optional) min = 0, // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/delete-row.md b/docs/examples/kotlin/tablesdb/delete-row.md index 3fcd409..6912afa 100644 --- a/docs/examples/kotlin/tablesdb/delete-row.md +++ b/docs/examples/kotlin/tablesdb/delete-row.md @@ -12,4 +12,5 @@ val result = tablesDB.deleteRow( databaseId = "", tableId = "", rowId = "", + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/delete-transaction.md b/docs/examples/kotlin/tablesdb/delete-transaction.md new file mode 100644 index 0000000..92c0074 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/delete-transaction.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDB = TablesDB(client) + +val result = tablesDB.deleteTransaction( + transactionId = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/get-row.md b/docs/examples/kotlin/tablesdb/get-row.md index b754cba..adea429 100644 --- a/docs/examples/kotlin/tablesdb/get-row.md +++ b/docs/examples/kotlin/tablesdb/get-row.md @@ -13,4 +13,5 @@ val result = tablesDB.getRow( tableId = "", rowId = "", queries = listOf(), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/get-transaction.md b/docs/examples/kotlin/tablesdb/get-transaction.md new file mode 100644 index 0000000..38b7c33 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/get-transaction.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDB = TablesDB(client) + +val result = tablesDB.getTransaction( + transactionId = "", +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/increment-row-column.md b/docs/examples/kotlin/tablesdb/increment-row-column.md index 230408a..1b679e1 100644 --- a/docs/examples/kotlin/tablesdb/increment-row-column.md +++ b/docs/examples/kotlin/tablesdb/increment-row-column.md @@ -15,4 +15,5 @@ val result = tablesDB.incrementRowColumn( column = "", value = 0, // (optional) max = 0, // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/list-rows.md b/docs/examples/kotlin/tablesdb/list-rows.md index 05d9ca3..6d2a4b8 100644 --- a/docs/examples/kotlin/tablesdb/list-rows.md +++ b/docs/examples/kotlin/tablesdb/list-rows.md @@ -12,4 +12,5 @@ val result = tablesDB.listRows( databaseId = "", tableId = "", queries = listOf(), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/list-transactions.md b/docs/examples/kotlin/tablesdb/list-transactions.md new file mode 100644 index 0000000..b7764c7 --- /dev/null +++ b/docs/examples/kotlin/tablesdb/list-transactions.md @@ -0,0 +1,13 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDB = TablesDB(client) + +val result = tablesDB.listTransactions( + queries = listOf(), // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/update-row.md b/docs/examples/kotlin/tablesdb/update-row.md index f99f8f2..a17f231 100644 --- a/docs/examples/kotlin/tablesdb/update-row.md +++ b/docs/examples/kotlin/tablesdb/update-row.md @@ -14,4 +14,5 @@ val result = tablesDB.updateRow( rowId = "", data = mapOf( "a" to "b" ), // (optional) permissions = listOf("read("any")"), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/update-transaction.md b/docs/examples/kotlin/tablesdb/update-transaction.md new file mode 100644 index 0000000..791649f --- /dev/null +++ b/docs/examples/kotlin/tablesdb/update-transaction.md @@ -0,0 +1,15 @@ +import io.appwrite.Client +import io.appwrite.coroutines.CoroutineCallback +import io.appwrite.services.TablesDB + +val client = Client(context) + .setEndpoint("https://.cloud.appwrite.io/v1") // Your API Endpoint + .setProject("") // Your project ID + +val tablesDB = TablesDB(client) + +val result = tablesDB.updateTransaction( + transactionId = "", + commit = false, // (optional) + rollback = false, // (optional) +) \ No newline at end of file diff --git a/docs/examples/kotlin/tablesdb/upsert-row.md b/docs/examples/kotlin/tablesdb/upsert-row.md index d82406a..074fa33 100644 --- a/docs/examples/kotlin/tablesdb/upsert-row.md +++ b/docs/examples/kotlin/tablesdb/upsert-row.md @@ -14,4 +14,5 @@ val result = tablesDB.upsertRow( rowId = "", data = mapOf( "a" to "b" ), // (optional) permissions = listOf("read("any")"), // (optional) + transactionId = "", // (optional) ) \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/Client.kt b/library/src/main/java/io/appwrite/Client.kt index c046dff..e8f73f8 100644 --- a/library/src/main/java/io/appwrite/Client.kt +++ b/library/src/main/java/io/appwrite/Client.kt @@ -87,7 +87,7 @@ class Client @JvmOverloads constructor( "x-sdk-name" to "Android", "x-sdk-platform" to "client", "x-sdk-language" to "android", - "x-sdk-version" to "11.1.0", + "x-sdk-version" to "11.2.0", "x-appwrite-response-format" to "1.8.0" ) config = mutableMapOf() diff --git a/library/src/main/java/io/appwrite/models/Transaction.kt b/library/src/main/java/io/appwrite/models/Transaction.kt new file mode 100644 index 0000000..baf32d3 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/Transaction.kt @@ -0,0 +1,70 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Transaction + */ +data class Transaction( + /** + * Transaction ID. + */ + @SerializedName("\$id") + val id: String, + + /** + * Transaction creation time in ISO 8601 format. + */ + @SerializedName("\$createdAt") + val createdAt: String, + + /** + * Transaction update date in ISO 8601 format. + */ + @SerializedName("\$updatedAt") + val updatedAt: String, + + /** + * Current status of the transaction. One of: pending, committing, committed, rolled_back, failed. + */ + @SerializedName("status") + val status: String, + + /** + * Number of operations in the transaction. + */ + @SerializedName("operations") + val operations: Long, + + /** + * Expiration time in ISO 8601 format. + */ + @SerializedName("expiresAt") + val expiresAt: String, + +) { + fun toMap(): Map = mapOf( + "\$id" to id as Any, + "\$createdAt" to createdAt as Any, + "\$updatedAt" to updatedAt as Any, + "status" to status as Any, + "operations" to operations as Any, + "expiresAt" to expiresAt as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = Transaction( + id = map["\$id"] as String, + createdAt = map["\$createdAt"] as String, + updatedAt = map["\$updatedAt"] as String, + status = map["status"] as String, + operations = (map["operations"] as Number).toLong(), + expiresAt = map["expiresAt"] as String, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/models/TransactionList.kt b/library/src/main/java/io/appwrite/models/TransactionList.kt new file mode 100644 index 0000000..1233ed4 --- /dev/null +++ b/library/src/main/java/io/appwrite/models/TransactionList.kt @@ -0,0 +1,38 @@ +package io.appwrite.models + +import com.google.gson.annotations.SerializedName +import io.appwrite.extensions.jsonCast + +/** + * Transaction List + */ +data class TransactionList( + /** + * Total number of transactions that matched your query. + */ + @SerializedName("total") + val total: Long, + + /** + * List of transactions. + */ + @SerializedName("transactions") + val transactions: List, + +) { + fun toMap(): Map = mapOf( + "total" to total as Any, + "transactions" to transactions.map { it.toMap() } as Any, + ) + + companion object { + + @Suppress("UNCHECKED_CAST") + fun from( + map: Map, + ) = TransactionList( + total = (map["total"] as Number).toLong(), + transactions = (map["transactions"] as List>).map { Transaction.from(map = it) }, + ) + } +} \ No newline at end of file diff --git a/library/src/main/java/io/appwrite/services/Databases.kt b/library/src/main/java/io/appwrite/services/Databases.kt index 17321df..417b4ce 100644 --- a/library/src/main/java/io/appwrite/services/Databases.kt +++ b/library/src/main/java/io/appwrite/services/Databases.kt @@ -14,12 +14,211 @@ import java.io.File */ class Databases(client: Client) : Service(client) { + /** + * List transactions across all databases. + * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @return [io.appwrite.models.TransactionList] + */ + @JvmOverloads + suspend fun listTransactions( + queries: List? = null, + ): io.appwrite.models.TransactionList { + val apiPath = "/databases/transactions" + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.TransactionList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.TransactionList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.TransactionList::class.java, + converter, + ) + } + + + /** + * Create a new transaction. + * + * @param ttl Seconds before the transaction expires. + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + suspend fun createTransaction( + ttl: Long? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/databases/transactions" + + val apiParams = mutableMapOf( + "ttl" to ttl, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + + /** + * Get a transaction by its unique ID. + * + * @param transactionId Transaction ID. + * @return [io.appwrite.models.Transaction] + */ + suspend fun getTransaction( + transactionId: String, + ): io.appwrite.models.Transaction { + val apiPath = "/databases/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + + /** + * Update a transaction, to either commit or roll back its operations. + * + * @param transactionId Transaction ID. + * @param commit Commit transaction? + * @param rollback Rollback transaction? + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + suspend fun updateTransaction( + transactionId: String, + commit: Boolean? = null, + rollback: Boolean? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/databases/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + "commit" to commit, + "rollback" to rollback, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + + /** + * Delete a transaction by its unique ID. + * + * @param transactionId Transaction ID. + * @return [Any] + */ + suspend fun deleteTransaction( + transactionId: String, + ): Any { + val apiPath = "/databases/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + + /** + * Create multiple operations in a single transaction. + * + * @param transactionId Transaction ID. + * @param operations Array of staged operations. + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + suspend fun createOperations( + transactionId: String, + operations: List? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/databases/transactions/{transactionId}/operations" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + "operations" to operations, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + /** * Get a list of all the user's documents in a given collection. You can use the query params to filter your results. * * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param 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 transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -31,6 +230,7 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.DocumentList { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -39,6 +239,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( ) @@ -62,6 +263,7 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param 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 transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.DocumentList] */ @Deprecated( @@ -74,10 +276,12 @@ class Databases(client: Client) : Service(client) { databaseId: String, collectionId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.DocumentList> = listDocuments( databaseId, collectionId, queries, + transactionId, nestedType = classOf(), ) @@ -89,6 +293,7 @@ class Databases(client: Client) : Service(client) { * @param 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 data Document data as JSON object. * @param 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 transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -102,6 +307,7 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents" @@ -112,6 +318,7 @@ class Databases(client: Client) : Service(client) { "documentId" to documentId, "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -138,6 +345,7 @@ class Databases(client: Client) : Service(client) { * @param 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 data Document data as JSON object. * @param 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 transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -152,12 +360,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = createDocument( databaseId, collectionId, documentId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -168,6 +378,7 @@ class Databases(client: Client) : Service(client) { * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document ID. * @param 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 transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -180,6 +391,7 @@ class Databases(client: Client) : Service(client) { collectionId: String, documentId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -189,6 +401,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( ) @@ -213,6 +426,7 @@ class Databases(client: Client) : Service(client) { * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document ID. * @param 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 transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -226,11 +440,13 @@ class Databases(client: Client) : Service(client) { collectionId: String, documentId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = getDocument( databaseId, collectionId, documentId, queries, + transactionId, nestedType = classOf(), ) @@ -242,6 +458,7 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -255,6 +472,7 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -265,6 +483,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -291,6 +510,7 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @param data Document data as JSON object. Include all required attributes of the document to be created or updated. * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -305,12 +525,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = upsertDocument( databaseId, collectionId, documentId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -322,6 +544,7 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @param data Document data as JSON object. Include only attribute and value pairs to be updated. * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -335,6 +558,7 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" @@ -345,6 +569,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -371,6 +596,7 @@ class Databases(client: Client) : Service(client) { * @param documentId Document ID. * @param data Document data as JSON object. Include only attribute and value pairs to be updated. * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -385,12 +611,14 @@ class Databases(client: Client) : Service(client) { documentId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = updateDocument( databaseId, collectionId, documentId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -400,16 +628,19 @@ class Databases(client: Client) : Service(client) { * @param databaseId Database ID. * @param collectionId Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection). * @param documentId Document ID. + * @param transactionId Transaction ID for staging the operation. * @return [Any] */ @Deprecated( message = "This API has been deprecated since 1.8.0. Please use `TablesDB.deleteRow` instead.", replaceWith = ReplaceWith("io.appwrite.services.TablesDB.deleteRow") ) + @JvmOverloads suspend fun deleteDocument( databaseId: String, collectionId: String, documentId: String, + transactionId: String? = null, ): Any { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}" .replace("{databaseId}", databaseId) @@ -417,6 +648,7 @@ class Databases(client: Client) : Service(client) { .replace("{documentId}", documentId) val apiParams = mutableMapOf( + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -440,6 +672,7 @@ class Databases(client: Client) : Service(client) { * @param attribute Attribute key. * @param value Value to increment the attribute by. The value must be a number. * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -454,6 +687,7 @@ class Databases(client: Client) : Service(client) { attribute: String, value: Double? = null, min: Double? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement" @@ -465,6 +699,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "value" to value, "min" to min, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -492,6 +727,7 @@ class Databases(client: Client) : Service(client) { * @param attribute Attribute key. * @param value Value to increment the attribute by. The value must be a number. * @param min Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -507,6 +743,7 @@ class Databases(client: Client) : Service(client) { attribute: String, value: Double? = null, min: Double? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = decrementDocumentAttribute( databaseId, collectionId, @@ -514,6 +751,7 @@ class Databases(client: Client) : Service(client) { attribute, value, min, + transactionId, nestedType = classOf(), ) @@ -526,6 +764,7 @@ class Databases(client: Client) : Service(client) { * @param attribute Attribute key. * @param value Value to increment the attribute by. The value must be a number. * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -540,6 +779,7 @@ class Databases(client: Client) : Service(client) { attribute: String, value: Double? = null, max: Double? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Document { val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment" @@ -551,6 +791,7 @@ class Databases(client: Client) : Service(client) { val apiParams = mutableMapOf( "value" to value, "max" to max, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -578,6 +819,7 @@ class Databases(client: Client) : Service(client) { * @param attribute Attribute key. * @param value Value to increment the attribute by. The value must be a number. * @param max Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Document] */ @Deprecated( @@ -593,6 +835,7 @@ class Databases(client: Client) : Service(client) { attribute: String, value: Double? = null, max: Double? = null, + transactionId: String? = null, ): io.appwrite.models.Document> = incrementDocumentAttribute( databaseId, collectionId, @@ -600,6 +843,7 @@ class Databases(client: Client) : Service(client) { attribute, value, max, + transactionId, nestedType = classOf(), ) diff --git a/library/src/main/java/io/appwrite/services/TablesDb.kt b/library/src/main/java/io/appwrite/services/TablesDb.kt index b05303f..ea65a17 100644 --- a/library/src/main/java/io/appwrite/services/TablesDb.kt +++ b/library/src/main/java/io/appwrite/services/TablesDb.kt @@ -14,12 +14,211 @@ import java.io.File */ class TablesDB(client: Client) : Service(client) { + /** + * List transactions across all databases. + * + * @param queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). + * @return [io.appwrite.models.TransactionList] + */ + @JvmOverloads + suspend fun listTransactions( + queries: List? = null, + ): io.appwrite.models.TransactionList { + val apiPath = "/tablesdb/transactions" + + val apiParams = mutableMapOf( + "queries" to queries, + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.TransactionList = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.TransactionList.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.TransactionList::class.java, + converter, + ) + } + + + /** + * Create a new transaction. + * + * @param ttl Seconds before the transaction expires. + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + suspend fun createTransaction( + ttl: Long? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/tablesdb/transactions" + + val apiParams = mutableMapOf( + "ttl" to ttl, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + + /** + * Get a transaction by its unique ID. + * + * @param transactionId Transaction ID. + * @return [io.appwrite.models.Transaction] + */ + suspend fun getTransaction( + transactionId: String, + ): io.appwrite.models.Transaction { + val apiPath = "/tablesdb/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "GET", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + + /** + * Update a transaction, to either commit or roll back its operations. + * + * @param transactionId Transaction ID. + * @param commit Commit transaction? + * @param rollback Rollback transaction? + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + suspend fun updateTransaction( + transactionId: String, + commit: Boolean? = null, + rollback: Boolean? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/tablesdb/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + "commit" to commit, + "rollback" to rollback, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "PATCH", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + + /** + * Delete a transaction by its unique ID. + * + * @param transactionId Transaction ID. + * @return [Any] + */ + suspend fun deleteTransaction( + transactionId: String, + ): Any { + val apiPath = "/tablesdb/transactions/{transactionId}" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + return client.call( + "DELETE", + apiPath, + apiHeaders, + apiParams, + responseType = Any::class.java, + ) + } + + + /** + * Create multiple operations in a single transaction. + * + * @param transactionId Transaction ID. + * @param operations Array of staged operations. + * @return [io.appwrite.models.Transaction] + */ + @JvmOverloads + suspend fun createOperations( + transactionId: String, + operations: List? = null, + ): io.appwrite.models.Transaction { + val apiPath = "/tablesdb/transactions/{transactionId}/operations" + .replace("{transactionId}", transactionId) + + val apiParams = mutableMapOf( + "operations" to operations, + ) + val apiHeaders = mutableMapOf( + "content-type" to "application/json", + ) + val converter: (Any) -> io.appwrite.models.Transaction = { + @Suppress("UNCHECKED_CAST") + io.appwrite.models.Transaction.from(map = it as Map) + } + return client.call( + "POST", + apiPath, + apiHeaders, + apiParams, + responseType = io.appwrite.models.Transaction::class.java, + converter, + ) + } + + /** * Get a list of all the user's rows in a given table. You can use the query params to filter your results. * * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @param 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 transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -27,6 +226,7 @@ class TablesDB(client: Client) : Service(client) { databaseId: String, tableId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.RowList { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -35,6 +235,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( ) @@ -58,6 +259,7 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the TablesDB service [server integration](https://appwrite.io/docs/products/databases/tables#create-table). * @param 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 transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.RowList] */ @JvmOverloads @@ -66,10 +268,12 @@ class TablesDB(client: Client) : Service(client) { databaseId: String, tableId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.RowList> = listRows( databaseId, tableId, queries, + transactionId, nestedType = classOf(), ) @@ -81,6 +285,7 @@ class TablesDB(client: Client) : Service(client) { * @param rowId Row 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 data Row data as JSON object. * @param 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 transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -90,6 +295,7 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows" @@ -100,6 +306,7 @@ class TablesDB(client: Client) : Service(client) { "rowId" to rowId, "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -126,6 +333,7 @@ class TablesDB(client: Client) : Service(client) { * @param rowId Row 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 data Row data as JSON object. * @param 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 transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -136,12 +344,14 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = createRow( databaseId, tableId, rowId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -152,6 +362,7 @@ class TablesDB(client: Client) : Service(client) { * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param rowId Row ID. * @param 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 transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -160,6 +371,7 @@ class TablesDB(client: Client) : Service(client) { tableId: String, rowId: String, queries: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" @@ -169,6 +381,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "queries" to queries, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( ) @@ -193,6 +406,7 @@ class TablesDB(client: Client) : Service(client) { * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param rowId Row ID. * @param 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 transactionId Transaction ID to read uncommitted changes within the transaction. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -202,11 +416,13 @@ class TablesDB(client: Client) : Service(client) { tableId: String, rowId: String, queries: List? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = getRow( databaseId, tableId, rowId, queries, + transactionId, nestedType = classOf(), ) @@ -218,6 +434,7 @@ class TablesDB(client: Client) : Service(client) { * @param rowId Row ID. * @param data Row data as JSON object. Include all required columns of the row to be created or updated. * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -227,6 +444,7 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" @@ -237,6 +455,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -263,6 +482,7 @@ class TablesDB(client: Client) : Service(client) { * @param rowId Row ID. * @param data Row data as JSON object. Include all required columns of the row to be created or updated. * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -273,12 +493,14 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = upsertRow( databaseId, tableId, rowId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -290,6 +512,7 @@ class TablesDB(client: Client) : Service(client) { * @param rowId Row ID. * @param data Row data as JSON object. Include only columns and value pairs to be updated. * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -299,6 +522,7 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" @@ -309,6 +533,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "data" to data, "permissions" to permissions, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -335,6 +560,7 @@ class TablesDB(client: Client) : Service(client) { * @param rowId Row ID. * @param data Row data as JSON object. Include only columns and value pairs to be updated. * @param permissions An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -345,12 +571,14 @@ class TablesDB(client: Client) : Service(client) { rowId: String, data: Any? = null, permissions: List? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = updateRow( databaseId, tableId, rowId, data, permissions, + transactionId, nestedType = classOf(), ) @@ -360,12 +588,15 @@ class TablesDB(client: Client) : Service(client) { * @param databaseId Database ID. * @param tableId Table ID. You can create a new table using the Database service [server integration](https://appwrite.io/docs/references/cloud/server-dart/tablesDB#createTable). * @param rowId Row ID. + * @param transactionId Transaction ID for staging the operation. * @return [Any] */ + @JvmOverloads suspend fun deleteRow( databaseId: String, tableId: String, rowId: String, + transactionId: String? = null, ): Any { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}" .replace("{databaseId}", databaseId) @@ -373,6 +604,7 @@ class TablesDB(client: Client) : Service(client) { .replace("{rowId}", rowId) val apiParams = mutableMapOf( + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -396,6 +628,7 @@ class TablesDB(client: Client) : Service(client) { * @param column Column key. * @param value Value to increment the column by. The value must be a number. * @param min Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -406,6 +639,7 @@ class TablesDB(client: Client) : Service(client) { column: String, value: Double? = null, min: Double? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement" @@ -417,6 +651,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "value" to value, "min" to min, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -444,6 +679,7 @@ class TablesDB(client: Client) : Service(client) { * @param column Column key. * @param value Value to increment the column by. The value must be a number. * @param min Minimum value for the column. If the current value is lesser than this value, an exception will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -455,6 +691,7 @@ class TablesDB(client: Client) : Service(client) { column: String, value: Double? = null, min: Double? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = decrementRowColumn( databaseId, tableId, @@ -462,6 +699,7 @@ class TablesDB(client: Client) : Service(client) { column, value, min, + transactionId, nestedType = classOf(), ) @@ -474,6 +712,7 @@ class TablesDB(client: Client) : Service(client) { * @param column Column key. * @param value Value to increment the column by. The value must be a number. * @param max Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -484,6 +723,7 @@ class TablesDB(client: Client) : Service(client) { column: String, value: Double? = null, max: Double? = null, + transactionId: String? = null, nestedType: Class, ): io.appwrite.models.Row { val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment" @@ -495,6 +735,7 @@ class TablesDB(client: Client) : Service(client) { val apiParams = mutableMapOf( "value" to value, "max" to max, + "transactionId" to transactionId, ) val apiHeaders = mutableMapOf( "content-type" to "application/json", @@ -522,6 +763,7 @@ class TablesDB(client: Client) : Service(client) { * @param column Column key. * @param value Value to increment the column by. The value must be a number. * @param max Maximum value for the column. If the current value is greater than this value, an error will be thrown. + * @param transactionId Transaction ID for staging the operation. * @return [io.appwrite.models.Row] */ @JvmOverloads @@ -533,6 +775,7 @@ class TablesDB(client: Client) : Service(client) { column: String, value: Double? = null, max: Double? = null, + transactionId: String? = null, ): io.appwrite.models.Row> = incrementRowColumn( databaseId, tableId, @@ -540,6 +783,7 @@ class TablesDB(client: Client) : Service(client) { column, value, max, + transactionId, nestedType = classOf(), )