2019-05-09 18:54:39 +12:00
# Database Service
## List Collections
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/database
2019-05-09 18:54:39 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/list-collections.md **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| search | string | Search term to filter your list results. | |
| limit | integer | Results limit value. By default will return maximum 25 results. Maximum of 100 results allowed per request. | 25 |
| offset | integer | Results offset. The default value is 0. Use this param to manage pagination. | 0 |
| orderType | string | Order result by ASC or DESC order. | ASC |
## Create Collection
```http request
2019-10-09 17:16:38 +13:00
POST https://appwrite.io/v1/database
2019-05-09 18:54:39 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/create-collection.md **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| name | string | Collection name. | |
2019-10-02 07:10:33 +13:00
| read | array | An array of strings with read permissions. [Learn more about permissions and roles ](/docs/permissions ). | [] |
| write | array | An array of strings with write permissions. [Learn more about permissions and roles ](/docs/permissions ). | [] |
2019-09-20 18:33:11 +12:00
| rules | array | Array of [rule objects ](/docs/rules ). Each rule define a collection field name, data type and validation | [] |
2019-05-09 18:54:39 +12:00
2019-08-07 02:00:08 +12:00
## Get Collection
2019-05-09 18:54:39 +12:00
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/database/{collectionId}
2019-05-09 18:54:39 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/get-collection.md **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| collectionId | string | **Required** Collection unique ID. | |
2019-08-07 02:00:08 +12:00
## Update Collection
2019-05-09 18:54:39 +12:00
```http request
2019-10-09 17:16:38 +13:00
PUT https://appwrite.io/v1/database/{collectionId}
2019-05-09 18:54:39 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/update-collection.md **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| collectionId | string | **Required** Collection unique ID. | |
2019-08-07 02:00:08 +12:00
| name | string | Collection name. | |
2019-10-02 07:10:33 +13:00
| read | array | An array of strings with read permissions. [Learn more about permissions and roles ](/docs/permissions ). | [] |
| write | array | An array of strings with write permissions. [Learn more about permissions and roles ](/docs/permissions ). | [] |
2019-09-20 18:33:11 +12:00
| rules | array | Array of [rule objects ](/docs/rules ). Each rule define a collection field name, data type and validation | [] |
2019-05-09 18:54:39 +12:00
2019-08-07 02:00:08 +12:00
## Delete Collection
2019-06-09 23:44:58 +12:00
```http request
2019-10-09 17:16:38 +13:00
DELETE https://appwrite.io/v1/database/{collectionId}
2019-06-09 23:44:58 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/delete-collection.md **
2019-06-09 23:44:58 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| collectionId | string | **Required** Collection unique ID. | |
2019-08-07 02:00:08 +12:00
## List Documents
2019-05-09 18:54:39 +12:00
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/database/{collectionId}/documents
2019-05-09 18:54:39 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/list-documents.md **
2019-08-07 02:00:08 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| collectionId | string | **Required** Collection unique ID. | |
| filters | array | Array of filter strings. Each filter is constructed from a key name, comparison operator (=, !=, > , < , < =, > =) and a value. You can also use a dot (.) separator in attribute names to filter by child document attributes. Examples: ' name=John Doe' or ' category.$uid> =5bed2d152c362' | [] |
| offset | integer | Offset value. Use this value to manage pagination. | 0 |
| limit | integer | Maximum number of documents to return in response. Use this value to manage pagination. | 50 |
| order-field | string | Document field that results will be sorted by. | $uid |
| order-type | string | Order direction. Possible values are DESC for descending order, or ASC for ascending order. | ASC |
| order-cast | string | Order field type casting. Possible values are int, string, date, time or datetime. The database will attempt to cast the order field to the value you pass here. The default value is a string. | string |
| search | string | Search query. Enter any free text search. The database will try to find a match against all document attributes and children. | |
| first | integer | Return only first document. Pass 1 for true or 0 for false. The default value is 0. | 0 |
| last | integer | Return only last document. Pass 1 for true or 0 for false. The default value is 0. | 0 |
## Create Document
```http request
2019-10-09 17:16:38 +13:00
POST https://appwrite.io/v1/database/{collectionId}/documents
2019-08-07 02:00:08 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/create-document.md **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| collectionId | string | **Required** Collection unique ID. | |
2019-08-07 02:00:08 +12:00
| data | string | Document data as JSON string. | |
2019-10-02 07:10:33 +13:00
| read | array | An array of strings with read permissions. [Learn more about permissions and roles ](/docs/permissions ). | [] |
| write | array | An array of strings with write permissions. [Learn more about permissions and roles ](/docs/permissions ). | [] |
2019-08-07 02:00:08 +12:00
| parentDocument | string | Parent document unique ID. Use when you want your new document to be a child of a parent document. | |
| parentProperty | string | Parent document property name. Use when you want your new document to be a child of a parent document. | |
| parentPropertyType | string | Parent document property connection type. You can set this value to **assign** , **append** or **prepend** , default value is assign. Use when you want your new document to be a child of a parent document. | assign |
2019-05-09 18:54:39 +12:00
## Get Document
```http request
2019-10-09 17:16:38 +13:00
GET https://appwrite.io/v1/database/{collectionId}/documents/{documentId}
2019-05-09 18:54:39 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/get-document.md **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| collectionId | string | **Required** Collection unique ID | |
| documentId | string | **Required** Document unique ID | |
## Update Document
```http request
2019-10-09 17:16:38 +13:00
PATCH https://appwrite.io/v1/database/{collectionId}/documents/{documentId}
2019-05-09 18:54:39 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/update-document.md **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| collectionId | string | **Required** Collection unique ID | |
| documentId | string | **Required** Document unique ID | |
| data | string | Document data as JSON string | |
2019-10-02 07:10:33 +13:00
| read | array | An array of strings with read permissions. [Learn more about permissions and roles ](/docs/permissions ). | [] |
| write | array | An array of strings with write permissions. [Learn more about permissions and roles ](/docs/permissions ). | [] |
2019-05-09 18:54:39 +12:00
## Delete Document
```http request
2019-10-09 17:16:38 +13:00
DELETE https://appwrite.io/v1/database/{collectionId}/documents/{documentId}
2019-05-09 18:54:39 +12:00
```
2019-10-09 17:16:38 +13:00
** /docs/references/database/delete-document.md **
2019-05-09 18:54:39 +12:00
### Parameters
| Field Name | Type | Description | Default |
| --- | --- | --- | --- |
| collectionId | string | **Required** Collection unique ID | |
| documentId | string | **Required** Document unique ID | |