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

Method QueryRoles

db/query.go:618–639  ·  view source on GitHub ↗

Retrieves role ids using the syncDocs or roles index, excluding deleted roles

(ctx context.Context, startKey string, limit int)

Source from the content-addressed store, hash-verified

616
617// Retrieves role ids using the syncDocs or roles index, excluding deleted roles
618func (context *DatabaseContext) QueryRoles(ctx context.Context, startKey string, limit int) (sgbucket.QueryResultIterator, error) {
619
620 // View Query
621 if context.Options.UseViews {
622 opts := map[string]interface{}{"stale": false}
623
624 if limit > 0 {
625 opts[QueryParamLimit] = limit
626 }
627
628 if startKey != "" {
629 opts[QueryParamStartKey] = startKey
630 }
631
632 return context.ViewQueryWithStats(ctx, context.MetadataStore, DesignDocSyncGateway(), ViewRolesExcludeDeleted, opts)
633 }
634
635 queryStatement, params := context.BuildRolesQuery(startKey, limit)
636
637 // N1QL Query
638 return N1QLQueryWithStats(ctx, context.MetadataStore, QueryRolesExcludeDeleted.name, queryStatement, params, base.RequestPlus, QueryRolesExcludeDeleted.adhoc, context.DbStats, context.Options.SlowQueryWarningThreshold)
639}
640
641// BuildRolesQuery builds the query statement and query parameters for a Roles N1QL query. Also used by unit tests to validate
642// query is covering.

Callers 2

getRoleIDsUsingIndexMethod · 0.95
TestRoleQueryFunction · 0.80

Calls 4

ViewQueryWithStatsMethod · 0.95
BuildRolesQueryMethod · 0.95
DesignDocSyncGatewayFunction · 0.85
N1QLQueryWithStatsFunction · 0.85

Tested by 1

TestRoleQueryFunction · 0.64