Skip to content

Commit 03e4d9f

Browse files
Merge pull request #65 from appwrite/dev
Add inc/dec
2 parents 27a2faf + 29430cb commit 03e4d9f

16 files changed

+264
-128
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log
22

3+
## 0.10.2
4+
5+
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
6+
* Add `sequence` support to `Document` model
7+
* Fix autocompletion not working for `Document` model even when generic is passed
8+
39
## 0.10.1
410

511
* Fix URL based methods like `getFileViewURL`, `getFilePreviewURL` etc. by adding the missing `projectId` to searchParams
@@ -28,4 +34,4 @@
2834
## 0.7.4
2935

3036
* Upgrade dependencies to resolve PlatformConstants error with Expo 53
31-
* Update doc examples to use new multi-region endpoint
37+
* Update doc examples to use new multi-region endpoint

docs/examples/databases/create-document.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ 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-
.setSession('') // The user session to authenticate with
6-
.setKey('') //
7-
.setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
5+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
86

97
const databases = new Databases(client);
108

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.decrementDocumentAttribute(
10+
'<DATABASE_ID>', // databaseId
11+
'<COLLECTION_ID>', // collectionId
12+
'<DOCUMENT_ID>', // documentId
13+
'', // attribute
14+
null, // value (optional)
15+
null // min (optional)
16+
);
17+
18+
console.log(result);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
.setProject('<YOUR_PROJECT_ID>'); // Your project ID
6+
7+
const databases = new Databases(client);
8+
9+
const result = await databases.incrementDocumentAttribute(
10+
'<DATABASE_ID>', // databaseId
11+
'<COLLECTION_ID>', // collectionId
12+
'<DOCUMENT_ID>', // documentId
13+
'', // attribute
14+
null, // value (optional)
15+
null // max (optional)
16+
);
17+
18+
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.10.1",
5+
"version": "0.11.0",
66
"license": "BSD-3-Clause",
77
"main": "dist/cjs/sdk.js",
88
"exports": {

src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class Client {
115115
'x-sdk-name': 'React Native',
116116
'x-sdk-platform': 'client',
117117
'x-sdk-language': 'reactnative',
118-
'x-sdk-version': '0.10.1',
118+
'x-sdk-version': '0.11.0',
119119
'X-Appwrite-Response-Format': '1.7.0',
120120
};
121121

src/models.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export namespace Models {
22
/**
33
* Documents List
44
*/
5-
export type DocumentList<Document extends Models.Document> = {
5+
export type DocumentList<Document extends Models.Document = Models.DefaultDocument> = {
66
/**
77
* Total number of documents documents that matched your query.
88
*/
@@ -67,7 +67,7 @@ export namespace Models {
6767
/**
6868
* Teams List
6969
*/
70-
export type TeamList<Preferences extends Models.Preferences> = {
70+
export type TeamList<Preferences extends Models.Preferences = Models.DefaultPreferences> = {
7171
/**
7272
* Total number of teams documents that matched your query.
7373
*/
@@ -189,6 +189,10 @@ export namespace Models {
189189
* Document ID.
190190
*/
191191
$id: string;
192+
/**
193+
* Document automatically incrementing ID.
194+
*/
195+
$sequence: number;
192196
/**
193197
* Collection ID.
194198
*/
@@ -303,7 +307,7 @@ export namespace Models {
303307
/**
304308
* User
305309
*/
306-
export type User<Preferences extends Models.Preferences> = {
310+
export type User<Preferences extends Models.Preferences = Models.DefaultPreferences> = {
307311
/**
308312
* User ID.
309313
*/
@@ -792,7 +796,7 @@ export namespace Models {
792796
/**
793797
* Team
794798
*/
795-
export type Team<Preferences extends Models.Preferences> = {
799+
export type Team<Preferences extends Models.Preferences = Models.DefaultPreferences> = {
796800
/**
797801
* Team ID.
798802
*/

0 commit comments

Comments
 (0)