Query to retrieve the set of user and role doc ids, using the syncDocs index
(ctx context.Context, startKey string, limit int)
| 552 | |
| 553 | // Query to retrieve the set of user and role doc ids, using the syncDocs index |
| 554 | func (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 |
| 585 | func (context *DatabaseContext) QueryUsers(ctx context.Context, startKey string, limit int) (sgbucket.QueryResultIterator, error) { |
no test coverage detected