Skip to content

Commit 39fdc6e

Browse files
committed
Add inc/dec
1 parent 151e7a0 commit 39fdc6e

File tree

11 files changed

+267
-7
lines changed

11 files changed

+267
-7
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![Maven Central](https://img.shields.io/maven-central/v/io.appwrite/sdk-for-android.svg?color=green&style=flat-square)
44
![License](https://img.shields.io/github/license/appwrite/sdk-for-android.svg?style=flat-square)
5-
![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square)
5+
![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square)
66
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
77
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
88
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
@@ -38,7 +38,7 @@ repositories {
3838
Next, add the dependency to your project's `build.gradle(.kts)` file:
3939

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

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

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.appwrite.services.Databases;
44

55
Client client = new Client(context)
66
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setAdmin("") //
78
.setSession("") // The user session to authenticate with
89
.setKey("") //
910
.setJWT("<YOUR_JWT>"); // Your secret JSON Web Token
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
8+
9+
Databases databases = new Databases(client);
10+
11+
databases.decrementDocumentAttribute(
12+
"<DATABASE_ID>", // databaseId
13+
"<COLLECTION_ID>", // collectionId
14+
"<DOCUMENT_ID>", // documentId
15+
"", // attribute
16+
0, // value (optional)
17+
0, // min (optional)
18+
new CoroutineCallback<>((result, error) -> {
19+
if (error != null) {
20+
error.printStackTrace();
21+
return;
22+
}
23+
24+
Log.d("Appwrite", result.toString());
25+
})
26+
);
27+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>"); // Your project ID
8+
9+
Databases databases = new Databases(client);
10+
11+
databases.incrementDocumentAttribute(
12+
"<DATABASE_ID>", // databaseId
13+
"<COLLECTION_ID>", // collectionId
14+
"<DOCUMENT_ID>", // documentId
15+
"", // attribute
16+
0, // value (optional)
17+
0, // max (optional)
18+
new CoroutineCallback<>((result, error) -> {
19+
if (error != null) {
20+
error.printStackTrace();
21+
return;
22+
}
23+
24+
Log.d("Appwrite", result.toString());
25+
})
26+
);
27+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import io.appwrite.services.Databases
44

55
val client = Client(context)
66
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setAdmin("") //
78
.setSession("") // The user session to authenticate with
89
.setKey("") //
910
.setJWT("<YOUR_JWT>") // Your secret JSON Web Token
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Databases
4+
5+
val client = Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
9+
val databases = Databases(client)
10+
11+
val result = databases.decrementDocumentAttribute(
12+
databaseId = "<DATABASE_ID>",
13+
collectionId = "<COLLECTION_ID>",
14+
documentId = "<DOCUMENT_ID>",
15+
attribute = "",
16+
value = 0, // (optional)
17+
min = 0, // (optional)
18+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Databases
4+
5+
val client = Client(context)
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
9+
val databases = Databases(client)
10+
11+
val result = databases.incrementDocumentAttribute(
12+
databaseId = "<DATABASE_ID>",
13+
collectionId = "<COLLECTION_ID>",
14+
documentId = "<DOCUMENT_ID>",
15+
attribute = "",
16+
value = 0, // (optional)
17+
max = 0, // (optional)
18+
)

library/src/main/java/io/appwrite/Client.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class Client @JvmOverloads constructor(
8787
"x-sdk-name" to "Android",
8888
"x-sdk-platform" to "client",
8989
"x-sdk-language" to "android",
90-
"x-sdk-version" to "8.1.0",
90+
"x-sdk-version" to "8.2.0",
9191
"x-appwrite-response-format" to "1.7.0"
9292
)
9393
config = mutableMapOf()

library/src/main/java/io/appwrite/enums/ImageFormat.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ enum class ImageFormat(val value: String) {
1414
@SerializedName("heic")
1515
HEIC("heic"),
1616
@SerializedName("avif")
17-
AVIF("avif");
17+
AVIF("avif"),
18+
@SerializedName("gif")
19+
GIF("gif");
1820

1921
override fun toString() = value
2022
}

library/src/main/java/io/appwrite/models/Document.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ data class Document<T>(
1313
@SerializedName("\$id")
1414
val id: String,
1515

16+
/**
17+
* Document automatically incrementing ID.
18+
*/
19+
@SerializedName("\$sequence")
20+
val sequence: Long,
21+
1622
/**
1723
* Collection ID.
1824
*/
@@ -51,6 +57,7 @@ data class Document<T>(
5157
) {
5258
fun toMap(): Map<String, Any> = mapOf(
5359
"\$id" to id as Any,
60+
"\$sequence" to sequence as Any,
5461
"\$collectionId" to collectionId as Any,
5562
"\$databaseId" to databaseId as Any,
5663
"\$createdAt" to createdAt as Any,
@@ -62,6 +69,7 @@ data class Document<T>(
6269
companion object {
6370
operator fun invoke(
6471
id: String,
72+
sequence: Long,
6573
collectionId: String,
6674
databaseId: String,
6775
createdAt: String,
@@ -70,6 +78,7 @@ data class Document<T>(
7078
data: Map<String, Any>
7179
) = Document<Map<String, Any>>(
7280
id,
81+
sequence,
7382
collectionId,
7483
databaseId,
7584
createdAt,
@@ -84,6 +93,7 @@ data class Document<T>(
8493
nestedType: Class<T>
8594
) = Document<T>(
8695
id = map["\$id"] as String,
96+
sequence = (map["\$sequence"] as Number).toLong(),
8797
collectionId = map["\$collectionId"] as String,
8898
databaseId = map["\$databaseId"] as String,
8999
createdAt = map["\$createdAt"] as String,

0 commit comments

Comments
 (0)