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

Method QueryPrincipals

db/query.go:554–582  ·  view source on GitHub ↗

Query to retrieve the set of user and role doc ids, using the syncDocs index

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

Source from the content-addressed store, hash-verified

552
553// Query to retrieve the set of user and role doc ids, using the syncDocs index
554func (context *DatabaseContext) QueryPrincipals(ctx context.Context, startKey string, limit int) (sgbucket.QueryResultIterator, error) {
555
556 // View Query
557 if context.Options.UseViews {
558 opts := map[string]interface{}{"stale": false}
559
560 if limit > 0 {
561 opts[QueryParamLimit] = limit
562 }
563
564 if startKey != "" {
565 opts[QueryParamStartKey] = startKey
566 }
567
568 return context.ViewQueryWithStats(ctx, context.MetadataStore, DesignDocSyncGateway(), ViewPrincipals, opts)
569 }
570
571 queryStatement := replaceIndexTokensQuery(QueryPrincipals.statement, sgIndexes[IndexSyncDocs], context.UseXattrs(), context.numIndexPartitions())
572
573 params := make(map[string]interface{})
574 params[QueryParamStartKey] = startKey
575
576 if limit > 0 {
577 queryStatement = fmt.Sprintf("%s LIMIT %d", queryStatement, limit)
578 }
579
580 // N1QL Query
581 return N1QLQueryWithStats(ctx, context.MetadataStore, QueryPrincipals.name, queryStatement, params, base.RequestPlus, QueryPrincipals.adhoc, context.DbStats, context.Options.SlowQueryWarningThreshold)
582}
583
584// Query to retrieve user details, using the syncDocs or users index
585func (context *DatabaseContext) QueryUsers(ctx context.Context, startKey string, limit int) (sgbucket.QueryResultIterator, error) {

Callers 1

Calls 6

ViewQueryWithStatsMethod · 0.95
UseXattrsMethod · 0.95
numIndexPartitionsMethod · 0.95
DesignDocSyncGatewayFunction · 0.85
replaceIndexTokensQueryFunction · 0.85
N1QLQueryWithStatsFunction · 0.85

Tested by

no test coverage detected