Skip to content

Commit de7c090

Browse files
committed
Add bulk API methods
1 parent e84b6a1 commit de7c090

File tree

11 files changed

+414
-4
lines changed

11 files changed

+414
-4
lines changed

README.md

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

4141
```groovy
42-
implementation("io.appwrite:sdk-for-kotlin:8.0.0")
42+
implementation("io.appwrite:sdk-for-kotlin:8.1.0-rc.1")
4343
```
4444

4545
### Maven
@@ -50,7 +50,7 @@ Add this to your project's `pom.xml` file:
5050
<dependency>
5151
<groupId>io.appwrite</groupId>
5252
<artifactId>sdk-for-kotlin</artifactId>
53-
<version>8.0.0</version>
53+
<version>8.1.0-rc.1</version>
5454
</dependency>
5555
</dependencies>
5656
```
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client()
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.setSession(""); // The user session to authenticate with
9+
10+
Databases databases = new Databases(client);
11+
12+
databases.createDocuments(
13+
"<DATABASE_ID>", // databaseId
14+
"<COLLECTION_ID>", // collectionId
15+
listOf(), // documents
16+
new CoroutineCallback<>((result, error) -> {
17+
if (error != null) {
18+
error.printStackTrace();
19+
return;
20+
}
21+
22+
System.out.println(result);
23+
})
24+
);
25+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client()
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.setKey("<YOUR_API_KEY>"); // Your secret API key
9+
10+
Databases databases = new Databases(client);
11+
12+
databases.deleteDocuments(
13+
"<DATABASE_ID>", // databaseId
14+
"<COLLECTION_ID>", // collectionId
15+
listOf(), // queries (optional)
16+
new CoroutineCallback<>((result, error) -> {
17+
if (error != null) {
18+
error.printStackTrace();
19+
return;
20+
}
21+
22+
System.out.println(result);
23+
})
24+
);
25+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client()
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.setKey("<YOUR_API_KEY>"); // Your secret API key
9+
10+
Databases databases = new Databases(client);
11+
12+
databases.updateDocuments(
13+
"<DATABASE_ID>", // databaseId
14+
"<COLLECTION_ID>", // collectionId
15+
mapOf( "a" to "b" ), // data (optional)
16+
listOf(), // queries (optional)
17+
new CoroutineCallback<>((result, error) -> {
18+
if (error != null) {
19+
error.printStackTrace();
20+
return;
21+
}
22+
23+
System.out.println(result);
24+
})
25+
);
26+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import io.appwrite.Client;
2+
import io.appwrite.coroutines.CoroutineCallback;
3+
import io.appwrite.services.Databases;
4+
5+
Client client = new Client()
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.setKey("<YOUR_API_KEY>"); // Your secret API key
9+
10+
Databases databases = new Databases(client);
11+
12+
databases.upsertDocuments(
13+
"<DATABASE_ID>", // databaseId
14+
"<COLLECTION_ID>", // collectionId
15+
listOf(), // documents (optional)
16+
new CoroutineCallback<>((result, error) -> {
17+
if (error != null) {
18+
error.printStackTrace();
19+
return;
20+
}
21+
22+
System.out.println(result);
23+
})
24+
);
25+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Databases
4+
5+
val client = Client()
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.setSession("") // The user session to authenticate with
9+
10+
val databases = Databases(client)
11+
12+
val response = databases.createDocuments(
13+
databaseId = "<DATABASE_ID>",
14+
collectionId = "<COLLECTION_ID>",
15+
documents = listOf()
16+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Databases
4+
5+
val client = Client()
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.setKey("<YOUR_API_KEY>") // Your secret API key
9+
10+
val databases = Databases(client)
11+
12+
val response = databases.deleteDocuments(
13+
databaseId = "<DATABASE_ID>",
14+
collectionId = "<COLLECTION_ID>",
15+
queries = listOf() // optional
16+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Databases
4+
5+
val client = Client()
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.setKey("<YOUR_API_KEY>") // Your secret API key
9+
10+
val databases = Databases(client)
11+
12+
val response = databases.updateDocuments(
13+
databaseId = "<DATABASE_ID>",
14+
collectionId = "<COLLECTION_ID>",
15+
data = mapOf( "a" to "b" ), // optional
16+
queries = listOf() // optional
17+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import io.appwrite.Client
2+
import io.appwrite.coroutines.CoroutineCallback
3+
import io.appwrite.services.Databases
4+
5+
val client = Client()
6+
.setEndpoint("https://<REGION>.cloud.appwrite.io/v1") // Your API Endpoint
7+
.setProject("<YOUR_PROJECT_ID>") // Your project ID
8+
.setKey("<YOUR_API_KEY>") // Your secret API key
9+
10+
val databases = Databases(client)
11+
12+
val response = databases.upsertDocuments(
13+
databaseId = "<DATABASE_ID>",
14+
collectionId = "<COLLECTION_ID>",
15+
documents = listOf() // optional
16+
)

src/main/kotlin/io/appwrite/Client.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ class Client @JvmOverloads constructor(
5858
init {
5959
headers = mutableMapOf(
6060
"content-type" to "application/json",
61-
"user-agent" to "AppwriteKotlinSDK/8.0.0 ${System.getProperty("http.agent")}",
61+
"user-agent" to "AppwriteKotlinSDK/8.1.0-rc.1 ${System.getProperty("http.agent")}",
6262
"x-sdk-name" to "Kotlin",
6363
"x-sdk-platform" to "server",
6464
"x-sdk-language" to "kotlin",
65-
"x-sdk-version" to "8.0.0",
65+
"x-sdk-version" to "8.1.0-rc.1",
6666
"x-appwrite-response-format" to "1.6.0",
6767
)
6868

0 commit comments

Comments
 (0)