mirror of
https://github.com/appwrite/sdk-for-android.git
synced 2026-04-07 19:17:49 +00:00
Add inc/dec
This commit is contained in:
@@ -4,6 +4,7 @@ import io.appwrite.services.Databases;
|
||||
|
||||
Client client = new Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setAdmin("") //
|
||||
.setSession("") // The user session to authenticate with
|
||||
.setKey("") //
|
||||
.setJWT("<YOUR_JWT>"); // Your secret JSON Web Token
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
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.decrementDocumentAttribute(
|
||||
"<DATABASE_ID>", // databaseId
|
||||
"<COLLECTION_ID>", // collectionId
|
||||
"<DOCUMENT_ID>", // documentId
|
||||
"", // attribute
|
||||
0, // value (optional)
|
||||
0, // min (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
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.incrementDocumentAttribute(
|
||||
"<DATABASE_ID>", // databaseId
|
||||
"<COLLECTION_ID>", // collectionId
|
||||
"<DOCUMENT_ID>", // documentId
|
||||
"", // attribute
|
||||
0, // value (optional)
|
||||
0, // max (optional)
|
||||
new CoroutineCallback<>((result, error) -> {
|
||||
if (error != null) {
|
||||
error.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d("Appwrite", result.toString());
|
||||
})
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.appwrite.services.Databases
|
||||
|
||||
val client = Client(context)
|
||||
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
|
||||
.setAdmin("") //
|
||||
.setSession("") // The user session to authenticate with
|
||||
.setKey("") //
|
||||
.setJWT("<YOUR_JWT>") // Your secret JSON Web Token
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
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.decrementDocumentAttribute(
|
||||
databaseId = "<DATABASE_ID>",
|
||||
collectionId = "<COLLECTION_ID>",
|
||||
documentId = "<DOCUMENT_ID>",
|
||||
attribute = "",
|
||||
value = 0, // (optional)
|
||||
min = 0, // (optional)
|
||||
)
|
||||
@@ -0,0 +1,18 @@
|
||||
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.incrementDocumentAttribute(
|
||||
databaseId = "<DATABASE_ID>",
|
||||
collectionId = "<COLLECTION_ID>",
|
||||
documentId = "<DOCUMENT_ID>",
|
||||
attribute = "",
|
||||
value = 0, // (optional)
|
||||
max = 0, // (optional)
|
||||
)
|
||||
Reference in New Issue
Block a user