How to access Couchbase ViewResults from golang

32 views
Skip to first unread message

N8 Sabes

unread,
Aug 27, 2015, 3:56:54 AM8/27/15
to Couchbase
I'm developing a server in golang with Couchbase (using the new Couchbase Go SDK). Unfortunately, I've hit a roadblock and cannot find any complete examples to reference.

When you query a view, how do you access:

1. the total number of rows returned?
2. access the key/value fields in the row returned by Next()

Seems like it should be obvious. Here is a snippet I'm using based on the example at:


myQuery := gocb.NewViewQuery("tokens", "blacklist_tokens")
rows := bucket.ExecuteViewQuery(myQuery)

// ??? How do you get the result (row) count, here?

var row interface{}
for rows.Next(&row) {
   fmt.Printf("Row: %+v\n", row)   // ??? How do your access the key and value fields, here?
}
if err := rows.Close(); err != nil {
   fmt.Printf("View query error: %s\n", err)
}


Thanks for any help with this.

Reply all
Reply to author
Forward
0 new messages