Retrieves role ids using the roles index, includes deleted roles
(ctx context.Context, startKey string, limit int)
| 661 | |
| 662 | // Retrieves role ids using the roles index, includes deleted roles |
| 663 | func (context *DatabaseContext) QueryAllRoles(ctx context.Context, startKey string, limit int) (sgbucket.QueryResultIterator, error) { |
| 664 | |
| 665 | // View Query |
| 666 | if context.Options.UseViews { |
| 667 | return nil, fmt.Errorf("QueryAllRoles doesn't support views") |
| 668 | } |
| 669 | |
| 670 | var queryStatement string |
| 671 | if !context.UseLegacySyncDocsIndex() { |
| 672 | queryStatement = replaceIndexTokensQuery(QueryAllRolesUsingRoleIdx.statement, sgIndexes[IndexRole], context.UseXattrs(), context.numIndexPartitions()) |
| 673 | } else { |
| 674 | queryStatement = replaceIndexTokensQuery(QueryAllRolesUsingSyncDocsIdx.statement, sgIndexes[IndexSyncDocs], context.UseXattrs(), context.numIndexPartitions()) |
| 675 | } |
| 676 | |
| 677 | params := make(map[string]interface{}) |
| 678 | params[QueryParamStartKey] = startKey |
| 679 | |
| 680 | if limit > 0 { |
| 681 | queryStatement = fmt.Sprintf("%s LIMIT %d", queryStatement, limit) |
| 682 | } |
| 683 | |
| 684 | // N1QL Query |
| 685 | return N1QLQueryWithStats(ctx, context.MetadataStore, QueryRolesExcludeDeleted.name, queryStatement, params, base.RequestPlus, QueryRolesExcludeDeleted.adhoc, context.DbStats, context.Options.SlowQueryWarningThreshold) |
| 686 | } |
| 687 | |
| 688 | type AllDocsViewQueryRow struct { |
| 689 | Key string |