Skip to content
This repository has been archived by the owner on Oct 17, 2019. It is now read-only.

deadcheat/tcb

Repository files navigation

tcb

Build Status Coverage Status GoDoc

takin' care of business

1rqml0

what is this ?

this is an adapter library for couchbase client gocb i made gocbadapter for that before, i want refactor and refine by recreating.

How to Use

Install

it's just same as traditional style go get github.com/deadcheat/tcb

Example

package main

import (
	"fmt"

	"github.com/deadcheat/tcb"
)

type Data struct {
	Text string
}

func main() {
	config := tcb.Configure{
		ConnectString: "couchbase://localhost",
		BucketConfigs: []tcb.BucketConfig{
			tcb.BucketConfig{
				Name:     "default",
				Password: "",
			},
		},
		User:     "Administrator",
		Password: "password",
	}
	c := tcb.NewCluster(config)
	if err := c.Open(); err != nil {
		panic(err)
	}
	defer c.CloseAll()
	o, _ := c.Operator("default")
	data := Data{
		Text: "TestData",
	}
	if _, err := o.Insert("key", &data, 0); err != nil {
		panic(err)
	}
	var m Data
	if _, err := o.Get("key", &m); err != nil {
		panic(err)
	}
	fmt.Println("data : ", m)
	if _, err := o.Remove("key"); err != nil {
		panic(err)
	}
}