Skip to content

Commit 796d461

Browse files
committed
chore: add setDevKey and upsertDocument methods
1 parent 9fa0199 commit 796d461

File tree

13 files changed

+87
-461
lines changed

13 files changed

+87
-461
lines changed

docs/examples/databases/create-document.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { Client, Databases } from "react-native-appwrite";
22

33
const client = new Client()
44
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5-
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
5+
.setSession('') // The user session to authenticate with
6+
.setKey('') //
7+
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
68

79
const databases = new Databases(client);
810

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Client, Databases } from "react-native-appwrite";
2+
3+
const client = new Client()
4+
.setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
5+
.setKey(''); //
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.createDocuments(
10+
'<DATABASE_ID>', // databaseId
11+
'<COLLECTION_ID>', // collectionId
12+
[] // documents
13+
);
14+
15+
console.log(result);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "react-native-appwrite",
33
"homepage": "https://appwrite.io/support",
44
"description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5-
"version": "0.9.0",
5+
"version": "0.9.1",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/client.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class Client {
114114
'x-sdk-name': 'React Native',
115115
'x-sdk-platform': 'client',
116116
'x-sdk-language': 'reactnative',
117-
'x-sdk-version': '0.9.0',
117+
'x-sdk-version': '0.9.1',
118118
'X-Appwrite-Response-Format': '1.7.0',
119119
};
120120

@@ -416,7 +416,7 @@ class Client {
416416
}
417417
}
418418

419-
async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}, responseType = 'json'): Promise<any> {
419+
async call(method: string, url: URL, headers: Headers = {}, params: Payload = {}): Promise<any> {
420420
method = method.toUpperCase();
421421

422422
headers = Object.assign({}, this.headers, headers);
@@ -469,8 +469,6 @@ class Client {
469469

470470
if (response.headers.get('content-type')?.includes('application/json')) {
471471
data = await response.json();
472-
} else if (responseType === 'arrayBuffer') {
473-
data = await response.arrayBuffer();
474472
} else {
475473
data = {
476474
message: await response.text()

src/services/account.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,5 +1457,4 @@ export class Account extends Service {
14571457
'content-type': 'application/json',
14581458
}, payload);
14591459
}
1460-
14611460
};

0 commit comments

Comments
 (0)