Skip to content

Commit c438b38

Browse files
authored
Merge pull request #42 from appwrite/dev
Add inc/dec
2 parents deb97b6 + 5bdd2a7 commit c438b38

18 files changed

+425
-23
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
# Change Log
1+
# Change Log
2+
3+
## 15.1.0
4+
5+
* Add `incrementDocumentAttribute` and `decrementDocumentAttribute` support to `Databases` service
6+
* Add `dart38` and `flutter332` support to runtime models
7+
* Add `gif` support to `ImageFormat` enum
8+
* Add `upsertDocument` support to `Databases` service
9+
* Add `sequence` support to `Document` model

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite PHP SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-php.svg?style=flat-square&v=1)
4-
![Version](https://img.shields.io/badge/api%20version-1.7.0-blue.svg?style=flat-square&v=1)
4+
![Version](https://img.shields.io/badge/api%20version-1.7.4-blue.svg?style=flat-square&v=1)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

docs/databases.md

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection
623623
POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents
624624
```
625625

626-
** Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. **
626+
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
627+
628+
Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. **
627629

628630
### Parameters
629631

@@ -638,7 +640,9 @@ POST https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collection
638640
PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents
639641
```
640642

641-
** Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
643+
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
644+
645+
Create or update Documents. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console.
642646
**
643647

644648
### Parameters
@@ -647,14 +651,16 @@ PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI
647651
| --- | --- | --- | --- |
648652
| databaseId | string | **Required** Database ID. | |
649653
| collectionId | string | **Required** Collection ID. | |
650-
| documents | array | Array of document data as JSON objects. May contain partial documents. | [] |
654+
| documents | array | Array of document data as JSON objects. May contain partial documents. | |
651655

652656

653657
```http request
654658
PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents
655659
```
656660

657-
** Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. **
661+
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
662+
663+
Update all documents that match your queries, if no queries are submitted then all documents are updated. You can pass only specific fields to be updated. **
658664

659665
### Parameters
660666

@@ -670,7 +676,9 @@ PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectio
670676
DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents
671677
```
672678

673-
** Bulk delete documents using queries, if no queries are passed then all documents are deleted. **
679+
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
680+
681+
Bulk delete documents using queries, if no queries are passed then all documents are deleted. **
674682

675683
### Parameters
676684

@@ -697,6 +705,25 @@ GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionI
697705
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. | [] |
698706

699707

708+
```http request
709+
PUT https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}
710+
```
711+
712+
** **WARNING: Experimental Feature** - This endpoint is experimental and not yet officially supported. It may be subject to breaking changes or removal in future versions.
713+
714+
Create or update a Document. Before using this route, you should create a new collection resource using either a [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection) API or directly from your database console. **
715+
716+
### Parameters
717+
718+
| Field Name | Type | Description | Default |
719+
| --- | --- | --- | --- |
720+
| databaseId | string | **Required** Database ID. | |
721+
| collectionId | string | **Required** Collection ID. | |
722+
| documentId | string | **Required** Document ID. | |
723+
| data | object | Document data as JSON object. Include all required attributes of the document to be created or updated. | {} |
724+
| permissions | array | An array of permissions strings. By default, the current permissions are inherited. [Learn more about permissions](https://appwrite.io/docs/permissions). | |
725+
726+
700727
```http request
701728
PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}
702729
```
@@ -729,6 +756,42 @@ DELETE https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collecti
729756
| documentId | string | **Required** Document ID. | |
730757

731758

759+
```http request
760+
PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/decrement
761+
```
762+
763+
** Decrement a specific attribute of a document by a given value. **
764+
765+
### Parameters
766+
767+
| Field Name | Type | Description | Default |
768+
| --- | --- | --- | --- |
769+
| databaseId | string | **Required** Database ID. | |
770+
| collectionId | string | **Required** Collection ID. | |
771+
| documentId | string | **Required** Document ID. | |
772+
| attribute | string | **Required** Attribute key. | |
773+
| value | number | Value to decrement the attribute by. The value must be a number. | 1 |
774+
| min | number | Minimum value for the attribute. If the current value is lesser than this value, an exception will be thrown. | |
775+
776+
777+
```http request
778+
PATCH https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents/{documentId}/{attribute}/increment
779+
```
780+
781+
** Increment a specific attribute of a document by a given value. **
782+
783+
### Parameters
784+
785+
| Field Name | Type | Description | Default |
786+
| --- | --- | --- | --- |
787+
| databaseId | string | **Required** Database ID. | |
788+
| collectionId | string | **Required** Collection ID. | |
789+
| documentId | string | **Required** Document ID. | |
790+
| attribute | string | **Required** Attribute key. | |
791+
| value | number | Value to increment the attribute by. The value must be a number. | 1 |
792+
| max | number | Maximum value for the attribute. If the current value is greater than this value, an error will be thrown. | |
793+
794+
732795
```http request
733796
GET https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/indexes
734797
```

docs/examples/databases/create-document.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ use Appwrite\Services\Databases;
55
66
$client = (new Client())
77
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
8-
->setSession('') // The user session to authenticate with
9-
->setKey('<YOUR_API_KEY>') // Your secret API key
10-
->setJWT('<YOUR_JWT>'); // Your secret JSON Web Token
8+
->setProject('<YOUR_PROJECT_ID>') // Your project ID
9+
->setSession(''); // The user session to authenticate with
1110

1211
$databases = new Databases($client);
1312

docs/examples/databases/create-documents.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use Appwrite\Services\Databases;
55
66
$client = (new Client())
77
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
8+
->setProject('<YOUR_PROJECT_ID>') // Your project ID
89
->setKey('<YOUR_API_KEY>'); // Your secret API key
910

1011
$databases = new Databases($client);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use Appwrite\Client;
4+
use Appwrite\Services\Databases;
5+
6+
$client = (new Client())
7+
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
8+
->setProject('<YOUR_PROJECT_ID>') // Your project ID
9+
->setKey('<YOUR_API_KEY>'); // Your secret API key
10+
11+
$databases = new Databases($client);
12+
13+
$result = $databases->decrementDocumentAttribute(
14+
databaseId: '<DATABASE_ID>',
15+
collectionId: '<COLLECTION_ID>',
16+
documentId: '<DOCUMENT_ID>',
17+
attribute: '',
18+
value: null, // optional
19+
min: null // optional
20+
);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
use Appwrite\Client;
4+
use Appwrite\Services\Databases;
5+
6+
$client = (new Client())
7+
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
8+
->setProject('<YOUR_PROJECT_ID>') // Your project ID
9+
->setKey('<YOUR_API_KEY>'); // Your secret API key
10+
11+
$databases = new Databases($client);
12+
13+
$result = $databases->incrementDocumentAttribute(
14+
databaseId: '<DATABASE_ID>',
15+
collectionId: '<COLLECTION_ID>',
16+
documentId: '<DOCUMENT_ID>',
17+
attribute: '',
18+
value: null, // optional
19+
max: null // optional
20+
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
use Appwrite\Client;
4+
use Appwrite\Services\Databases;
5+
6+
$client = (new Client())
7+
->setEndpoint('https://<REGION>.cloud.appwrite.io/v1') // Your API Endpoint
8+
->setProject('<YOUR_PROJECT_ID>') // Your project ID
9+
->setSession(''); // The user session to authenticate with
10+
11+
$databases = new Databases($client);
12+
13+
$result = $databases->upsertDocument(
14+
databaseId: '<DATABASE_ID>',
15+
collectionId: '<COLLECTION_ID>',
16+
documentId: '<DOCUMENT_ID>',
17+
data: [],
18+
permissions: ["read("any")"] // optional
19+
);

docs/examples/databases/upsert-documents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ $databases = new Databases($client);
1313
$result = $databases->upsertDocuments(
1414
databaseId: '<DATABASE_ID>',
1515
collectionId: '<COLLECTION_ID>',
16-
documents: [] // optional
16+
documents: []
1717
);

docs/tokens.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ GET https://cloud.appwrite.io/v1/tokens/buckets/{bucketId}/files/{fileId}
2020
POST https://cloud.appwrite.io/v1/tokens/buckets/{bucketId}/files/{fileId}
2121
```
2222

23-
** Create a new token. A token is linked to a file. Token can be passed as a header or request get parameter. **
23+
** Create a new token. A token is linked to a file. Token can be passed as a request URL search parameter. **
2424

2525
### Parameters
2626

0 commit comments

Comments
 (0)