Golang demo using appwrite. This is a guide about how to use appwrite rest api for database resource with golang.
First, you need to run appwrite. I recommend to you to follow the official appwrite guide in the getting start section. Its a shortcut ussing docker:
docker run -it --rm \
--volume /var/run/docker.sock:/var/run/docker.sock \
--volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
--entrypoint="install" \
appwrite/appwrite:0.10.4
run the script
/bin/sh run.sh
You need to to modify env vars set in run.sh using your own
- BASEPATH
- PORT
- PROJECT_ID
- TOKEN
It project use the appwrite provided apis. Fow now, only database endpoint are implement in this project.
- Create new collection
- List all avaiable collections
- Create a new document using the id of inserted collection
Is required to set payload for create collection in the format below
{
"data": {
"key": "value3"
}
}
The data key is mandatory. key is the registered key in Collection.CollectionCreateInputRule.
If you modify the value of key, modify it in the create collection payload too.
inputRule := Collection.CollectionCreateInputRule{
Label: "label",
Key: "myKey",
Type: "text",
Default: "no set",
Required: false,
Array: false,
}
{
"data": {
"myKey": "value4"
}
}
The value of Label is for web interface