Retrieves role ids using the syncDocs or roles index, excluding deleted roles
(ctx context.Context, startKey string, limit int)
| 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) { |
| 619 | |
| 620 | // View Query |
| 621 | if context.Options.UseViews { |
| 622 | opts := map[string]interface{}{"stale": false} |
| 623 | |
| 624 | if limit > 0 { |
| 625 | opts[QueryParamLimit] = limit |
| 626 | } |
| 627 | |
| 628 | if startKey != "" { |
| 629 | opts[QueryParamStartKey] = startKey |
| 630 | } |
| 631 | |
| 632 | return context.ViewQueryWithStats(ctx, context.MetadataStore, DesignDocSyncGateway(), ViewRolesExcludeDeleted, opts) |
| 633 | } |
| 634 | |
| 635 | queryStatement, params := context.BuildRolesQuery(startKey, limit) |
| 636 | |
| 637 | // N1QL Query |
| 638 | return N1QLQueryWithStats(ctx, context.MetadataStore, QueryRolesExcludeDeleted.name, queryStatement, params, base.RequestPlus, QueryRolesExcludeDeleted.adhoc, context.DbStats, context.Options.SlowQueryWarningThreshold) |
| 639 | } |
| 640 | |
| 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. |