mirror of
https://github.com/appwrite/sdk-for-android.git
synced 2026-04-07 19:17:49 +00:00
Add transactions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
<dependency>
|
||||
<groupId>io.appwrite</groupId>
|
||||
<artifactId>sdk-for-android</artifactId>
|
||||
<version>11.1.0</version>
|
||||
<version>11.2.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
|
||||
@@ -20,6 +20,7 @@ databases.createDocument(
|
||||
"isAdmin" to false
|
||||
), // data
|
||||
listOf("read("any")"), // permissions (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
|
||||
|
||||
Databases databases = new Databases(client);
|
||||
|
||||
databases.createOperations(
|
||||
"<TRANSACTION_ID>", // transactionId
|
||||
listOf(
|
||||
{
|
||||
"action": "create",
|
||||
"databaseId": "<DATABASE_ID>",
|
||||
"collectionId": "<COLLECTION_ID>",
|
||||
"documentId": "<DOCUMENT_ID>",
|
||||
"data": {
|
||||
"name": "Walter O'Brien"
|
||||
}
|
||||
}
|
||||
), // operations (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // 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());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ databases.decrementDocumentAttribute(
|
||||
"", // attribute
|
||||
0, // value (optional)
|
||||
0, // min (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -12,6 +12,7 @@ databases.deleteDocument(
|
||||
"<DATABASE_ID>", // databaseId
|
||||
"<COLLECTION_ID>", // collectionId
|
||||
"<DOCUMENT_ID>", // documentId
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
|
||||
|
||||
Databases databases = new Databases(client);
|
||||
|
||||
databases.deleteTransaction(
|
||||
"<TRANSACTION_ID>", // transactionId
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -13,6 +13,7 @@ databases.getDocument(
|
||||
"<COLLECTION_ID>", // collectionId
|
||||
"<DOCUMENT_ID>", // documentId
|
||||
listOf(), // queries (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
|
||||
|
||||
Databases databases = new Databases(client);
|
||||
|
||||
databases.getTransaction(
|
||||
"<TRANSACTION_ID>", // transactionId
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ databases.incrementDocumentAttribute(
|
||||
"", // attribute
|
||||
0, // value (optional)
|
||||
0, // max (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -12,6 +12,7 @@ databases.listDocuments(
|
||||
"<DATABASE_ID>", // databaseId
|
||||
"<COLLECTION_ID>", // collectionId
|
||||
listOf(), // queries (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // 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());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ databases.updateDocument(
|
||||
"<DOCUMENT_ID>", // documentId
|
||||
mapOf( "a" to "b" ), // data (optional)
|
||||
listOf("read("any")"), // permissions (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
|
||||
|
||||
Databases databases = new Databases(client);
|
||||
|
||||
databases.updateTransaction(
|
||||
"<TRANSACTION_ID>", // transactionId
|
||||
false, // commit (optional)
|
||||
false, // rollback (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ databases.upsertDocument(
|
||||
"<DOCUMENT_ID>", // documentId
|
||||
mapOf( "a" to "b" ), // data
|
||||
listOf("read("any")"), // permissions (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
|
||||
|
||||
TablesDB tablesDB = new TablesDB(client);
|
||||
|
||||
tablesDB.createOperations(
|
||||
"<TRANSACTION_ID>", // transactionId
|
||||
listOf(
|
||||
{
|
||||
"action": "create",
|
||||
"databaseId": "<DATABASE_ID>",
|
||||
"tableId": "<TABLE_ID>",
|
||||
"rowId": "<ROW_ID>",
|
||||
"data": {
|
||||
"name": "Walter O'Brien"
|
||||
}
|
||||
}
|
||||
), // operations (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -20,6 +20,7 @@ tablesDB.createRow(
|
||||
"isAdmin" to false
|
||||
), // data
|
||||
listOf("read("any")"), // permissions (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // 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());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ tablesDB.decrementRowColumn(
|
||||
"", // column
|
||||
0, // value (optional)
|
||||
0, // min (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -12,6 +12,7 @@ tablesDB.deleteRow(
|
||||
"<DATABASE_ID>", // databaseId
|
||||
"<TABLE_ID>", // tableId
|
||||
"<ROW_ID>", // rowId
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
|
||||
|
||||
TablesDB tablesDB = new TablesDB(client);
|
||||
|
||||
tablesDB.deleteTransaction(
|
||||
"<TRANSACTION_ID>", // transactionId
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -13,6 +13,7 @@ tablesDB.getRow(
|
||||
"<TABLE_ID>", // tableId
|
||||
"<ROW_ID>", // rowId
|
||||
listOf(), // queries (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
|
||||
|
||||
TablesDB tablesDB = new TablesDB(client);
|
||||
|
||||
tablesDB.getTransaction(
|
||||
"<TRANSACTION_ID>", // transactionId
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -15,6 +15,7 @@ tablesDB.incrementRowColumn(
|
||||
"", // column
|
||||
0, // value (optional)
|
||||
0, // max (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -12,6 +12,7 @@ tablesDB.listRows(
|
||||
"<DATABASE_ID>", // databaseId
|
||||
"<TABLE_ID>", // tableId
|
||||
listOf(), // queries (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // 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());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ tablesDB.updateRow(
|
||||
"<ROW_ID>", // rowId
|
||||
mapOf( "a" to "b" ), // data (optional)
|
||||
listOf("read("any")"), // permissions (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -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://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
|
||||
|
||||
TablesDB tablesDB = new TablesDB(client);
|
||||
|
||||
tablesDB.updateTransaction(
|
||||
"<TRANSACTION_ID>", // transactionId
|
||||
false, // commit (optional)
|
||||
false, // rollback (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -14,6 +14,7 @@ tablesDB.upsertRow(
|
||||
"<ROW_ID>", // rowId
|
||||
mapOf( "a" to "b" ), // data (optional)
|
||||
listOf("read("any")"), // permissions (optional)
|
||||
"<TRANSACTION_ID>", // transactionId (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
|
||||
@@ -20,4 +20,5 @@ val result = databases.createDocument(
|
||||
"isAdmin" to false
|
||||
),
|
||||
permissions = listOf("read("any")"), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.Databases
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val databases = Databases(client)
|
||||
|
||||
val result = databases.createOperations(
|
||||
transactionId = "<TRANSACTION_ID>",
|
||||
operations = listOf(
|
||||
{
|
||||
"action": "create",
|
||||
"databaseId": "<DATABASE_ID>",
|
||||
"collectionId": "<COLLECTION_ID>",
|
||||
"documentId": "<DOCUMENT_ID>",
|
||||
"data": {
|
||||
"name": "Walter O'Brien"
|
||||
}
|
||||
}
|
||||
), // (optional)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.Databases
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val databases = Databases(client)
|
||||
|
||||
val result = databases.createTransaction(
|
||||
ttl = 60, // (optional)
|
||||
)
|
||||
@@ -15,4 +15,5 @@ val result = databases.decrementDocumentAttribute(
|
||||
attribute = "",
|
||||
value = 0, // (optional)
|
||||
min = 0, // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -12,4 +12,5 @@ val result = databases.deleteDocument(
|
||||
databaseId = "<DATABASE_ID>",
|
||||
collectionId = "<COLLECTION_ID>",
|
||||
documentId = "<DOCUMENT_ID>",
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.Databases
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val databases = Databases(client)
|
||||
|
||||
val result = databases.deleteTransaction(
|
||||
transactionId = "<TRANSACTION_ID>",
|
||||
)
|
||||
@@ -13,4 +13,5 @@ val result = databases.getDocument(
|
||||
collectionId = "<COLLECTION_ID>",
|
||||
documentId = "<DOCUMENT_ID>",
|
||||
queries = listOf(), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.Databases
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val databases = Databases(client)
|
||||
|
||||
val result = databases.getTransaction(
|
||||
transactionId = "<TRANSACTION_ID>",
|
||||
)
|
||||
@@ -15,4 +15,5 @@ val result = databases.incrementDocumentAttribute(
|
||||
attribute = "",
|
||||
value = 0, // (optional)
|
||||
max = 0, // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -12,4 +12,5 @@ val result = databases.listDocuments(
|
||||
databaseId = "<DATABASE_ID>",
|
||||
collectionId = "<COLLECTION_ID>",
|
||||
queries = listOf(), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.Databases
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val databases = Databases(client)
|
||||
|
||||
val result = databases.listTransactions(
|
||||
queries = listOf(), // (optional)
|
||||
)
|
||||
@@ -14,4 +14,5 @@ val result = databases.updateDocument(
|
||||
documentId = "<DOCUMENT_ID>",
|
||||
data = mapOf( "a" to "b" ), // (optional)
|
||||
permissions = listOf("read("any")"), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.Databases
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val databases = Databases(client)
|
||||
|
||||
val result = databases.updateTransaction(
|
||||
transactionId = "<TRANSACTION_ID>",
|
||||
commit = false, // (optional)
|
||||
rollback = false, // (optional)
|
||||
)
|
||||
@@ -14,4 +14,5 @@ val result = databases.upsertDocument(
|
||||
documentId = "<DOCUMENT_ID>",
|
||||
data = mapOf( "a" to "b" ),
|
||||
permissions = listOf("read("any")"), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.TablesDB
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val tablesDB = TablesDB(client)
|
||||
|
||||
val result = tablesDB.createOperations(
|
||||
transactionId = "<TRANSACTION_ID>",
|
||||
operations = listOf(
|
||||
{
|
||||
"action": "create",
|
||||
"databaseId": "<DATABASE_ID>",
|
||||
"tableId": "<TABLE_ID>",
|
||||
"rowId": "<ROW_ID>",
|
||||
"data": {
|
||||
"name": "Walter O'Brien"
|
||||
}
|
||||
}
|
||||
), // (optional)
|
||||
)
|
||||
@@ -20,4 +20,5 @@ val result = tablesDB.createRow(
|
||||
"isAdmin" to false
|
||||
),
|
||||
permissions = listOf("read("any")"), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.TablesDB
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val tablesDB = TablesDB(client)
|
||||
|
||||
val result = tablesDB.createTransaction(
|
||||
ttl = 60, // (optional)
|
||||
)
|
||||
@@ -15,4 +15,5 @@ val result = tablesDB.decrementRowColumn(
|
||||
column = "",
|
||||
value = 0, // (optional)
|
||||
min = 0, // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -12,4 +12,5 @@ val result = tablesDB.deleteRow(
|
||||
databaseId = "<DATABASE_ID>",
|
||||
tableId = "<TABLE_ID>",
|
||||
rowId = "<ROW_ID>",
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.TablesDB
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val tablesDB = TablesDB(client)
|
||||
|
||||
val result = tablesDB.deleteTransaction(
|
||||
transactionId = "<TRANSACTION_ID>",
|
||||
)
|
||||
@@ -13,4 +13,5 @@ val result = tablesDB.getRow(
|
||||
tableId = "<TABLE_ID>",
|
||||
rowId = "<ROW_ID>",
|
||||
queries = listOf(), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.TablesDB
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val tablesDB = TablesDB(client)
|
||||
|
||||
val result = tablesDB.getTransaction(
|
||||
transactionId = "<TRANSACTION_ID>",
|
||||
)
|
||||
@@ -15,4 +15,5 @@ val result = tablesDB.incrementRowColumn(
|
||||
column = "",
|
||||
value = 0, // (optional)
|
||||
max = 0, // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -12,4 +12,5 @@ val result = tablesDB.listRows(
|
||||
databaseId = "<DATABASE_ID>",
|
||||
tableId = "<TABLE_ID>",
|
||||
queries = listOf(), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,13 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.TablesDB
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val tablesDB = TablesDB(client)
|
||||
|
||||
val result = tablesDB.listTransactions(
|
||||
queries = listOf(), // (optional)
|
||||
)
|
||||
@@ -14,4 +14,5 @@ val result = tablesDB.updateRow(
|
||||
rowId = "<ROW_ID>",
|
||||
data = mapOf( "a" to "b" ), // (optional)
|
||||
permissions = listOf("read("any")"), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -0,0 +1,15 @@
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.coroutines.CoroutineCallback
|
||||
import io.appwrite.services.TablesDB
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setProject("<YOUR_PROJECT_ID>") // Your project ID
|
||||
|
||||
val tablesDB = TablesDB(client)
|
||||
|
||||
val result = tablesDB.updateTransaction(
|
||||
transactionId = "<TRANSACTION_ID>",
|
||||
commit = false, // (optional)
|
||||
rollback = false, // (optional)
|
||||
)
|
||||
@@ -14,4 +14,5 @@ val result = tablesDB.upsertRow(
|
||||
rowId = "<ROW_ID>",
|
||||
data = mapOf( "a" to "b" ), // (optional)
|
||||
permissions = listOf("read("any")"), // (optional)
|
||||
transactionId = "<TRANSACTION_ID>", // (optional)
|
||||
)
|
||||
@@ -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()
|
||||
|
||||
@@ -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<String, Any> = 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<String, Any>,
|
||||
) = 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,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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<Transaction>,
|
||||
|
||||
) {
|
||||
fun toMap(): Map<String, Any> = mapOf(
|
||||
"total" to total as Any,
|
||||
"transactions" to transactions.map { it.toMap() } as Any,
|
||||
)
|
||||
|
||||
companion object {
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun from(
|
||||
map: Map<String, Any>,
|
||||
) = TransactionList(
|
||||
total = (map["total"] as Number).toLong(),
|
||||
transactions = (map["transactions"] as List<Map<String, Any>>).map { Transaction.from(map = it) },
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -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<String>? = null,
|
||||
): io.appwrite.models.TransactionList {
|
||||
val apiPath = "/databases/transactions"
|
||||
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"queries" to queries,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.TransactionList = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.TransactionList.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<String, Any?>(
|
||||
"ttl" to ttl,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"content-type" to "application/json",
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.Transaction = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.Transaction.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<String, Any?>(
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.Transaction = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.Transaction.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<String, Any?>(
|
||||
"commit" to commit,
|
||||
"rollback" to rollback,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"content-type" to "application/json",
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.Transaction = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.Transaction.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<String, Any?>(
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<Any>? = null,
|
||||
): io.appwrite.models.Transaction {
|
||||
val apiPath = "/databases/transactions/{transactionId}/operations"
|
||||
.replace("{transactionId}", transactionId)
|
||||
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"operations" to operations,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"content-type" to "application/json",
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.Transaction = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.Transaction.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -31,6 +230,7 @@ class Databases(client: Client) : Service(client) {
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
queries: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.DocumentList<T> {
|
||||
val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents"
|
||||
@@ -39,6 +239,7 @@ class Databases(client: Client) : Service(client) {
|
||||
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"queries" to queries,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
)
|
||||
@@ -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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -74,10 +276,12 @@ class Databases(client: Client) : Service(client) {
|
||||
databaseId: String,
|
||||
collectionId: String,
|
||||
queries: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.DocumentList<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -102,6 +307,7 @@ class Databases(client: Client) : Service(client) {
|
||||
documentId: String,
|
||||
data: Any,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Document<T> {
|
||||
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<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -152,12 +360,14 @@ class Databases(client: Client) : Service(client) {
|
||||
documentId: String,
|
||||
data: Any,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.Document<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -180,6 +391,7 @@ class Databases(client: Client) : Service(client) {
|
||||
collectionId: String,
|
||||
documentId: String,
|
||||
queries: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Document<T> {
|
||||
val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
|
||||
@@ -189,6 +401,7 @@ class Databases(client: Client) : Service(client) {
|
||||
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"queries" to queries,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
)
|
||||
@@ -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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -226,11 +440,13 @@ class Databases(client: Client) : Service(client) {
|
||||
collectionId: String,
|
||||
documentId: String,
|
||||
queries: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.Document<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -255,6 +472,7 @@ class Databases(client: Client) : Service(client) {
|
||||
documentId: String,
|
||||
data: Any,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Document<T> {
|
||||
val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
|
||||
@@ -265,6 +483,7 @@ class Databases(client: Client) : Service(client) {
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"data" to data,
|
||||
"permissions" to permissions,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -305,12 +525,14 @@ class Databases(client: Client) : Service(client) {
|
||||
documentId: String,
|
||||
data: Any,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.Document<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -335,6 +558,7 @@ class Databases(client: Client) : Service(client) {
|
||||
documentId: String,
|
||||
data: Any? = null,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Document<T> {
|
||||
val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}"
|
||||
@@ -345,6 +569,7 @@ class Databases(client: Client) : Service(client) {
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"data" to data,
|
||||
"permissions" to permissions,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -385,12 +611,14 @@ class Databases(client: Client) : Service(client) {
|
||||
documentId: String,
|
||||
data: Any? = null,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.Document<Map<String, Any>> = 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<String, Any?>(
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -454,6 +687,7 @@ class Databases(client: Client) : Service(client) {
|
||||
attribute: String,
|
||||
value: Double? = null,
|
||||
min: Double? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Document<T> {
|
||||
val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement"
|
||||
@@ -465,6 +699,7 @@ class Databases(client: Client) : Service(client) {
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"value" to value,
|
||||
"min" to min,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@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<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@Deprecated(
|
||||
@@ -540,6 +779,7 @@ class Databases(client: Client) : Service(client) {
|
||||
attribute: String,
|
||||
value: Double? = null,
|
||||
max: Double? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Document<T> {
|
||||
val apiPath = "/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment"
|
||||
@@ -551,6 +791,7 @@ class Databases(client: Client) : Service(client) {
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"value" to value,
|
||||
"max" to max,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@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<Map<String, Any>> = incrementDocumentAttribute(
|
||||
databaseId,
|
||||
collectionId,
|
||||
@@ -600,6 +843,7 @@ class Databases(client: Client) : Service(client) {
|
||||
attribute,
|
||||
value,
|
||||
max,
|
||||
transactionId,
|
||||
nestedType = classOf(),
|
||||
)
|
||||
|
||||
|
||||
@@ -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<String>? = null,
|
||||
): io.appwrite.models.TransactionList {
|
||||
val apiPath = "/tablesdb/transactions"
|
||||
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"queries" to queries,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.TransactionList = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.TransactionList.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<String, Any?>(
|
||||
"ttl" to ttl,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"content-type" to "application/json",
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.Transaction = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.Transaction.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<String, Any?>(
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.Transaction = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.Transaction.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<String, Any?>(
|
||||
"commit" to commit,
|
||||
"rollback" to rollback,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"content-type" to "application/json",
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.Transaction = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.Transaction.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<String, Any?>(
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<Any>? = null,
|
||||
): io.appwrite.models.Transaction {
|
||||
val apiPath = "/tablesdb/transactions/{transactionId}/operations"
|
||||
.replace("{transactionId}", transactionId)
|
||||
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"operations" to operations,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"content-type" to "application/json",
|
||||
)
|
||||
val converter: (Any) -> io.appwrite.models.Transaction = {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
io.appwrite.models.Transaction.from(map = it as Map<String, Any>)
|
||||
}
|
||||
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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -27,6 +226,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
queries: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.RowList<T> {
|
||||
val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows"
|
||||
@@ -35,6 +235,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"queries" to queries,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
)
|
||||
@@ -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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -66,10 +268,12 @@ class TablesDB(client: Client) : Service(client) {
|
||||
databaseId: String,
|
||||
tableId: String,
|
||||
queries: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.RowList<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -90,6 +295,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
rowId: String,
|
||||
data: Any,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Row<T> {
|
||||
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<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -136,12 +344,14 @@ class TablesDB(client: Client) : Service(client) {
|
||||
rowId: String,
|
||||
data: Any,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.Row<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -160,6 +371,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
tableId: String,
|
||||
rowId: String,
|
||||
queries: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Row<T> {
|
||||
val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}"
|
||||
@@ -169,6 +381,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"queries" to queries,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
)
|
||||
@@ -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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -202,11 +416,13 @@ class TablesDB(client: Client) : Service(client) {
|
||||
tableId: String,
|
||||
rowId: String,
|
||||
queries: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.Row<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -227,6 +444,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
rowId: String,
|
||||
data: Any? = null,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Row<T> {
|
||||
val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}"
|
||||
@@ -237,6 +455,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"data" to data,
|
||||
"permissions" to permissions,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -273,12 +493,14 @@ class TablesDB(client: Client) : Service(client) {
|
||||
rowId: String,
|
||||
data: Any? = null,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.Row<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -299,6 +522,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
rowId: String,
|
||||
data: Any? = null,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Row<T> {
|
||||
val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}"
|
||||
@@ -309,6 +533,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"data" to data,
|
||||
"permissions" to permissions,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -345,12 +571,14 @@ class TablesDB(client: Client) : Service(client) {
|
||||
rowId: String,
|
||||
data: Any? = null,
|
||||
permissions: List<String>? = null,
|
||||
transactionId: String? = null,
|
||||
): io.appwrite.models.Row<Map<String, Any>> = 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<String, Any?>(
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -406,6 +639,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
column: String,
|
||||
value: Double? = null,
|
||||
min: Double? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Row<T> {
|
||||
val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/decrement"
|
||||
@@ -417,6 +651,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"value" to value,
|
||||
"min" to min,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@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<Map<String, Any>> = 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<T>]
|
||||
*/
|
||||
@JvmOverloads
|
||||
@@ -484,6 +723,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
column: String,
|
||||
value: Double? = null,
|
||||
max: Double? = null,
|
||||
transactionId: String? = null,
|
||||
nestedType: Class<T>,
|
||||
): io.appwrite.models.Row<T> {
|
||||
val apiPath = "/tablesdb/{databaseId}/tables/{tableId}/rows/{rowId}/{column}/increment"
|
||||
@@ -495,6 +735,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
val apiParams = mutableMapOf<String, Any?>(
|
||||
"value" to value,
|
||||
"max" to max,
|
||||
"transactionId" to transactionId,
|
||||
)
|
||||
val apiHeaders = mutableMapOf<String, String>(
|
||||
"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<T>]
|
||||
*/
|
||||
@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<Map<String, Any>> = incrementRowColumn(
|
||||
databaseId,
|
||||
tableId,
|
||||
@@ -540,6 +783,7 @@ class TablesDB(client: Client) : Service(client) {
|
||||
column,
|
||||
value,
|
||||
max,
|
||||
transactionId,
|
||||
nestedType = classOf(),
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user