Files
appwrite-generated-ui-funct…/functions/Get Collections/README.md

115 lines
3.2 KiB
Markdown

# Get Collections
Gets a list of all the collections for the configured database.
## 🤖 Documentation
Simple function similar to typical "hello world" example, but instead, we return a simple JSON that tells everyone how awesome developers are.
<!-- Update with your description, for example 'Create Stripe payment and return payment URL' -->
_Example input:_
This function expects no input
<!-- If input is expected, add example -->
_Example output:_
<!-- Update with your expected output -->
```json
{
"total":1,
"collections":[{"$id":"62f5d20fa7b5d8dc341b",
"$createdAt":1660277263,
"$updatedAt":1660277425,
"$read":[],
"$write":[],
"databaseId":"62f5d0b37b7d4b8716ac",
"name":"tasks",
"enabled":true,
"permission":"document",
"attributes":[
{
"key":"name",
"type":"string",
"status":"available",
"required":true,
"array":false,
"size":255,
"default":null
},
{
"key":"completed",
"type":"boolean",
"status":"available",
"required":true,
"array":false,
"default":null
}
],
"indexes":[
{
"key":"completed_index",
"type":"key",
"status":"available",
"attributes":[
"completed"
],
"orders":[
"ASC"
]
},
{
"key":"updated_at_index",
"type":"key",
"status":"available",
"attributes":[
"$updatedAt"
],
"orders":[
"ASC"
]
},
{
"key":"name_index",
"type":"fulltext",
"status":"available",
"attributes":[
"name"
],
"orders":[
"ASC"
]
}
]
}
]
}
```
## 📝 Environment Variables
List of environment variables used by this cloud function:
- **APPWRITE_FUNCTION_ENDPOINT** - Endpoint of Appwrite project
- **APPWRITE_FUNCTION_API_KEY** - Appwrite API Key
- **APPWRITE_FUNCTION_PROJECT_ID** - Appwrite Project ID
- **DATABASE_ID** - Appwrite Database ID
<!-- Add your custom environment variables -->
## 🚀 Deployment
There are two ways of deploying the Appwrite function, both having the same results, but each using a different process. We highly recommend using CLI deployment to achieve the best experience.
### Using CLI
Make sure you have [Appwrite CLI](https://appwrite.io/docs/command-line#installation) installed, and you have successfully logged into your Appwrite server. To make sure Appwrite CLI is ready, you can use the command `appwrite client --debug` and it should respond with green text `✓ Success`.
Make sure you are in the same folder as your `appwrite.json` file and run `appwrite deploy function` to deploy your function. You will be prompted to select which functions you want to deploy.
### Manual using tar.gz
Manual deployment has no requirements and uses Appwrite Console to deploy the tag. First, enter the folder of your function. Then, create a tarball of the whole folder and gzip it. After creating `.tar.gz` file, visit Appwrite Console, click on the `Deploy Tag` button and switch to the `Manual` tab. There, set the `entrypoint` to `src/index.js`, and upload the file we just generated.