tigris-client-go

module
v1.0.0-alpha.8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: Apache-2.0

README

Tigris Golang client

Go Report Build Status Build Status codecov

Install

go get github.com/tigrisdata/tigris-client-go@latest

Example

package example

import (
    "context"
    "fmt"

    "github.com/tigrisdata/tigris-client-go/driver"
)

func example() error {
    ctx := context.TODO()

    token := "{auth token here}" // optional

    drv, err := driver.NewDriver(ctx, "localhost:8081", &driver.Config{Token: token})
    if err != nil {
        return err
    }

    err = drv.CreateOrUpdateCollection(ctx, "db1", "coll1",
        driver.Schema(`{
            "name" : "coll1",
            "properties": {
               "Key1": { "type": "string" },
               "Field1": { "type": "integer" }
            },
            "primary_key": ["Key1"] }`))
    if err != nil {
        return err
    }

    _, err = drv.Insert(ctx, "db1", "coll1", []driver.Document{
            driver.Document(`{"Key1": "vK1", "Field1": 1}`) })
    if err != nil {
        return err
    }

    // Nil Filter value {} means full table scan.
    it, err := drv.Read(ctx, "db1", "coll1", driver.Filter(`{"Key1" : "vK1"}`), nil)
    if err != nil {
        return err
    }

    var doc driver.Document
    for it.Next(&doc) {
        fmt.Printf("%s\n", string(doc))
    }

    if err := it.Err(); err != nil {
        return err
    }

    return nil
}

Development

sh scripts/install_build_deps.sh
sh scripts/install_test_deps.sh
make test

License

This software is licensed under the Apache 2.0.

Directories

Path Synopsis
api
client/v1/api
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.
server/v1
Package api is a reverse proxy.
Package api is a reverse proxy.
Package filter provides methods to build logical filters.
Package filter provides methods to build logical filters.

Jump to

Keyboard shortcuts

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