This is a listing of various examples used for the Couchbase Go SDK GA Release Blog.
Last active
September 25, 2015 13:36
-
-
Save brett19/cda48d18388209f0f98b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cluster, _ := gocb.Connect("couchbase://localhost") | |
bucket, _ := cluster.OpenBucket("default", "") | |
var value interface{} | |
cas, err := myBucket.GetReplica("document_name", &value, 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cluster, _ := gocb.Connect("couchbases://localhost") | |
bucket, _ := cluster.OpenBucket("default", "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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