(ctx context.Context, ddoc, name string, params map[string]interface{})
| 255 | } |
| 256 | |
| 257 | func (c *Collection) executeViewQuery(ctx context.Context, ddoc, name string, params map[string]interface{}) (*gocb.ViewResultRaw, error) { |
| 258 | viewResult := sgbucket.ViewResult{} |
| 259 | viewResult.Rows = sgbucket.ViewRows{} |
| 260 | |
| 261 | viewOpts, optsErr := createViewOptions(ctx, params) |
| 262 | if optsErr != nil { |
| 263 | return nil, optsErr |
| 264 | } |
| 265 | |
| 266 | c.Bucket.waitForAvailQueryOp() |
| 267 | goCbViewResult, err := c.Collection.Bucket().ViewQuery(ddoc, name, viewOpts) |
| 268 | |
| 269 | // On timeout, return an typed error |
| 270 | if isGoCBQueryTimeoutError(err) { |
| 271 | c.Bucket.releaseQueryOp() |
| 272 | return nil, ErrViewTimeoutError |
| 273 | } else if err != nil { |
| 274 | c.Bucket.releaseQueryOp() |
| 275 | return nil, pkgerrors.WithStack(err) |
| 276 | } |
| 277 | |
| 278 | return goCbViewResult.Raw(), nil |
| 279 | } |
| 280 | |
| 281 | // Applies the viewquery options as specified in the params map to the gocb.ViewOptions |
| 282 | func createViewOptions(ctx context.Context, params map[string]interface{}) (viewOpts *gocb.ViewOptions, err error) { |
no test coverage detected