Golang与Couchbase集成问题

huangapple go评论89阅读模式
英文:

Golang with couchbase integration issue

问题

我正在使用与Couchbase集成的Go语言库go-couchbase。它可以连接到Couchbase并检索数据。然而,我在使用这个API时遇到了一个问题,即如何发送起始键(start key)、跳过值(skip value)和限制值(limit value)。因为我自己没有找到相关的功能。

请问有没有任何方法可以发送这些值到Couchbase并检索数据?

英文:

I'm using golang with couchbase integration component called go-couchbase. It's enable to connect with couchbase and retrieve data. However I have a problem to send start key and skip value and limit value with this API. Because there is no functionality found by myself.

url : - github.com/couchbaselabs/go-couchbase

Please let me know any method to send these values to couchbase and retrieve data?

答案1

得分: 2

那个起始键(start_key)只在一处提到,作为couhbase视图的参数

// View executes a view.
//
// The ddoc parameter is just the bare name of your design doc without
// the "_design/" prefix.
//
// Parameters are string keys with values that correspond to couchbase
// view parameters. Primitive should work fairly naturally (booleans,
// ints, strings, etc...) and other values will attempt to be JSON
// marshaled (useful for array indexing on on view keys, for example).
//
// Example:
//
// res, err := couchbase.View("myddoc", "myview", map[string]interface{}{
// "group_level": 2,
// "start_key": []interface{}{"thing"},
// "end_key": []interface{}{"thing", map[string]string{}},
// "stale": false,
// })
func (b *Bucket) View(ddoc, name string, params map[string]interface{}) (ViewResult, error) {

我猜skip(在“使用Couchbase进行分页”中提到)只是另一个要添加到params map[string]interface{}中的参数。

英文:

That start key is only mentioned once, as a parameter to a couhbase view:

// View executes a view.
//
// The ddoc parameter is just the bare name of your design doc without
// the "_design/" prefix.
//
// Parameters are string keys with values that correspond to couchbase
// view parameters. Primitive should work fairly naturally (booleans,
// ints, strings, etc...) and other values will attempt to be JSON
// marshaled (useful for array indexing on on view keys, for example).
//
// Example:
//
// res, err := couchbase.View("myddoc", "myview", map[string]interface{}{
// "group_level": 2,
// "start_key": []interface{}{"thing"},
// "end_key": []interface{}{"thing", map[string]string{}},
// "stale": false,
// })
func (b *Bucket) View(ddoc, name string, params map[string]interface{}) (ViewResult, error) {

I suppose the skip one (mentioned in "Pagination with Couchbase") is just another parameter to add to the params map[string]interface{}.

huangapple
  • 本文由 发表于 2014年10月29日 12:09:19
  • 转载请务必保留本文链接:https://go.coder-hub.com/26622651.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定