Skip to content

Instantly share code, notes, and snippets.

@jchris
Forked from brett19/_README.md
Last active September 25, 2015 13:29
Show Gist options
  • Save jchris/6be1afd42d4629c8f895 to your computer and use it in GitHub Desktop.
Save jchris/6be1afd42d4629c8f895 to your computer and use it in GitHub Desktop.

This is a listing of various examples used for the Couchbase Go SDK GA Release Blog.

Blog Post

cluster, _ := gocb.Connect("couchbase://localhost")
bucket, _ := cluster.OpenBucket("default", "")
var items []gocb.BulkOp
items = append(items, &gocb.InsertOp{Key: "document_name_1", Value: "Hello World 1"})
items = append(items, &gocb.InsertOp{Key: "document_name_2", Value: "Hello World 2"})
err := bucket.Do(items)
cluster, _ := gocb.Connect("couchbase://localhost")
bucket, _ := cluster.OpenBucket("default", "")
query := gocb.NewN1qlQuery("SELECT * FROM default")
rows, _ := bucket.ExecuteN1qlQuery(query)
var row interface{}
for rows.Next(&row) {
fmt.Printf("Row: %+v\n", row)
}
rows.Close()
cluster, _ := gocb.Connect("couchbase://localhost")
bucket, _ := cluster.OpenBucket("default", "")
var value interface{}
cas, err := myBucket.GetReplica("document_name", &value, 0)
cluster, _ := gocb.Connect("couchbases://localhost")
bucket, _ := cluster.OpenBucket("default", "")
cluster, _ := gocb.Connect("couchbase://localhost")
bucket, _ := cluster.OpenBucket("default", "")
query := gocb.NewViewQuery("beer", "by_name")
rows, _ := bucket.ExecuteViewQuery(query)
var row interface{}
for rows.Next(&row) {
fmt.Printf("Row: %+v\n", row)
}
rows.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment