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)
| 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. |
| 600 | func (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 |
| 618 | func (context *DatabaseContext) QueryRoles(ctx context.Context, startKey string, limit int) (sgbucket.QueryResultIterator, error) { |