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

Method BuildRolesQuery

db/query.go:643–660  ·  view source on GitHub ↗

BuildRolesQuery builds the query statement and query parameters for a Roles N1QL query. Also used by unit tests to validate query is covering.

(startKey string, limit int)

Source from the content-addressed store, hash-verified

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.
643func (context *DatabaseContext) BuildRolesQuery(startKey string, limit int) (string, map[string]interface{}) {
644
645 var queryStatement string
646 if !context.UseLegacySyncDocsIndex() {
647 queryStatement = replaceIndexTokensQuery(QueryRolesExcludeDeletedUsingRoleIdx.statement, sgIndexes[IndexRole], context.UseXattrs(), context.numIndexPartitions())
648 } else {
649 queryStatement = replaceIndexTokensQuery(QueryRolesExcludeDeleted.statement, sgIndexes[IndexSyncDocs], context.UseXattrs(), context.numIndexPartitions())
650 }
651
652 params := make(map[string]interface{})
653 params[QueryParamStartKey] = startKey
654
655 if limit > 0 {
656 queryStatement = fmt.Sprintf("%s LIMIT %d", queryStatement, limit)
657 }
658
659 return queryStatement, params
660}
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) {

Callers 2

QueryRolesMethod · 0.95
TestAllPrincipalIDsFunction · 0.80

Calls 4

UseXattrsMethod · 0.95
numIndexPartitionsMethod · 0.95
replaceIndexTokensQueryFunction · 0.85

Tested by 1

TestAllPrincipalIDsFunction · 0.64