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

Method QueryAllRoles

db/query.go:663–686  ·  view source on GitHub ↗

Retrieves role ids using the roles index, includes deleted roles

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

Source from the content-addressed store, hash-verified

661
662// Retrieves role ids using the roles index, includes deleted roles
663func (context *DatabaseContext) QueryAllRoles(ctx context.Context, startKey string, limit int) (sgbucket.QueryResultIterator, error) {
664
665 // View Query
666 if context.Options.UseViews {
667 return nil, fmt.Errorf("QueryAllRoles doesn't support views")
668 }
669
670 var queryStatement string
671 if !context.UseLegacySyncDocsIndex() {
672 queryStatement = replaceIndexTokensQuery(QueryAllRolesUsingRoleIdx.statement, sgIndexes[IndexRole], context.UseXattrs(), context.numIndexPartitions())
673 } else {
674 queryStatement = replaceIndexTokensQuery(QueryAllRolesUsingSyncDocsIdx.statement, sgIndexes[IndexSyncDocs], context.UseXattrs(), context.numIndexPartitions())
675 }
676
677 params := make(map[string]interface{})
678 params[QueryParamStartKey] = startKey
679
680 if limit > 0 {
681 queryStatement = fmt.Sprintf("%s LIMIT %d", queryStatement, limit)
682 }
683
684 // N1QL Query
685 return N1QLQueryWithStats(ctx, context.MetadataStore, QueryRolesExcludeDeleted.name, queryStatement, params, base.RequestPlus, QueryRolesExcludeDeleted.adhoc, context.DbStats, context.Options.SlowQueryWarningThreshold)
686}
687
688type AllDocsViewQueryRow struct {
689 Key string

Callers 2

getRoleIDsUsingIndexMethod · 0.95
TestRoleQueryFunction · 0.80

Calls 6

UseXattrsMethod · 0.95
numIndexPartitionsMethod · 0.95
replaceIndexTokensQueryFunction · 0.85
N1QLQueryWithStatsFunction · 0.85
ErrorfMethod · 0.80

Tested by 1

TestRoleQueryFunction · 0.64