MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / QueryRoleAccess

Method QueryRoleAccess

db/query.go:460–478  ·  view source on GitHub ↗

Query to compute the set of roles granted to the specified user via the Sync Function

(ctx context.Context, username string)

Source from the content-addressed store, hash-verified

458
459// Query to compute the set of roles granted to the specified user via the Sync Function
460func (c *DatabaseCollection) QueryRoleAccess(ctx context.Context, username string) (sgbucket.QueryResultIterator, error) {
461
462 // View Query
463 if c.useViews() {
464 opts := map[string]interface{}{"stale": false, "key": username}
465 return c.dbCtx.ViewQueryWithStats(ctx, c.dataStore, DesignDocSyncGateway(), ViewRoleAccess, opts)
466 }
467
468 // N1QL Query
469 if username == "" {
470 base.WarnfCtx(ctx, "QueryRoleAccess called with empty username")
471 return &EmptyResultIterator{}, nil
472 }
473
474 accessQueryStatement := c.buildRoleAccessQuery(username)
475 params := make(map[string]interface{}, 0)
476 params[QueryParamUserName] = username
477 return N1QLQueryWithStats(ctx, c.dataStore, QueryTypeRoleAccess, accessQueryStatement, params, base.RequestPlus, QueryRoleAccess.adhoc, c.dbStats(), c.slowQueryWarningThreshold())
478}
479
480// Builds the query statement for a roleAccess N1QL query.
481func (c *DatabaseCollection) buildRoleAccessQuery(username string) string {

Callers 2

ComputeRolesForUserMethod · 0.95
TestRoleAccessQueryFunction · 0.80

Calls 8

useViewsMethod · 0.95
buildRoleAccessQueryMethod · 0.95
dbStatsMethod · 0.95
WarnfCtxFunction · 0.92
DesignDocSyncGatewayFunction · 0.85
N1QLQueryWithStatsFunction · 0.85
ViewQueryWithStatsMethod · 0.80

Tested by 1

TestRoleAccessQueryFunction · 0.64