appwrite-sdk-go

module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2023 License: BSD-3-Clause

README

Appwrite Go SDK

License Version Build Status

WORK IN PROGRESS - NOT READY FOR USAGE

This repository is maintained solely to support illa-builder. It should not be used in production environments.

Installation

To install using go get:

go get github.com/illacloud/appwrite-sdk-go

Testing the SDK

  • clone this repo.

  • create a project and within this project a collection.

  • configure the documents in the collection to have a key = hello.

  • Then inject these environment variables:

    export YOUR_ENDPOINT=https://appwrite.io/v1  
    export YOUR_PROJECT_ID=6…8  
    export YOUR_KEY="7055781…cd95"  
    export COLLECTION_ID=616a095b20180  
    

Create main.go file with:

package main

import (
	"log"
	"os"
	"time"

	"github.com/illacloud/appwrite-sdk-go/appwrite"
)

func main() {
	client := appwrite.NewClient(10 * time.Second)
	client.SetEndpoint(os.Getenv("YOUR_ENDPOINT"))
	client.SetProject(os.Getenv("YOUR_PROJECT_ID"))
	client.SetKey(os.Getenv("YOUR_KEY"))

	db := appwrite.NewDatabase(client)
	data := map[string]string{
		"hello": "world",
	}
	var EmptyArray = []interface{}{}
	doc, err := db.CreateDocument(
		os.Getenv("COLLECTION_ID"),
		data,
		EmptyArray,
		EmptyArray,
		"",
		"",
		"",
	)
	if err != nil {
		log.Printf("Error creating document: %v", err)
	}
	log.Printf("Created document: %v", doc)
}
  • After that, run the following

    % go run main.go
    2021/10/16 03:41:17 Created document: map[$collection:616a095b20180 $id:616a2dbd4df16 $permissions:map[read:[] write:[]] hello:world]

Contribution

This library is auto-generated by Appwrite custom SDK Generator. This repository is maintained solely to support illa-builder. External contributions are not accepted at this time. To learn more about how you can help us improve this SDK, please check the Appwrite SDK Generator contribution guide.

License

Please see the BSD-3-Clause license file for more information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL