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

Method BuildUsersQuery

db/query.go:600–615  ·  view source on GitHub ↗

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

(startKey string, limit int)

Source from the content-addressed store, hash-verified

598// BuildUsersQuery builds the query statement and query parameters for a Users N1QL query. Also used by unit tests to validate
599// query is covering.
600func (context *DatabaseContext) BuildUsersQuery(startKey string, limit int) (string, map[string]interface{}) {
601 var queryStatement string
602 if !context.UseLegacySyncDocsIndex() {
603 queryStatement = replaceIndexTokensQuery(QueryUsers.statement, sgIndexes[IndexUser], context.UseXattrs(), context.numIndexPartitions())
604 } else {
605 queryStatement = replaceIndexTokensQuery(QueryUsersUsingSyncDocsIdx.statement, sgIndexes[IndexSyncDocs], context.UseXattrs(), context.numIndexPartitions())
606 }
607
608 params := make(map[string]interface{})
609 params[QueryParamStartKey] = startKey
610
611 if limit > 0 {
612 queryStatement = fmt.Sprintf("%s LIMIT %d", queryStatement, limit)
613 }
614 return queryStatement, params
615}
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) {

Callers 2

QueryUsersMethod · 0.95
TestAllPrincipalIDsFunction · 0.80

Calls 4

UseXattrsMethod · 0.95
numIndexPartitionsMethod · 0.95
replaceIndexTokensQueryFunction · 0.85

Tested by 1

TestAllPrincipalIDsFunction · 0.64