AllDocs returns all non-deleted documents in the bucket between startKey and endKey
(ctx context.Context, startKey string, endKey string)
| 703 | |
| 704 | // AllDocs returns all non-deleted documents in the bucket between startKey and endKey |
| 705 | func (c *DatabaseCollection) QueryAllDocs(ctx context.Context, startKey string, endKey string) (sgbucket.QueryResultIterator, error) { |
| 706 | |
| 707 | // View Query |
| 708 | if c.useViews() { |
| 709 | opts := Body{"stale": false, "reduce": false} |
| 710 | if startKey != "" { |
| 711 | opts[QueryParamStartKey] = startKey |
| 712 | } |
| 713 | if endKey != "" { |
| 714 | opts[QueryParamEndKey] = endKey |
| 715 | } |
| 716 | return c.dbCtx.ViewQueryWithStats(ctx, c.dataStore, DesignDocSyncHousekeeping(), ViewAllDocs, opts) |
| 717 | } |
| 718 | |
| 719 | // N1QL Query |
| 720 | allDocsQueryStatement := replaceSyncTokensQuery(QueryAllDocs.statement, c.UseXattrs()) |
| 721 | allDocsQueryStatement = replaceIndexTokensQuery(allDocsQueryStatement, sgIndexes[IndexAllDocs], c.UseXattrs(), c.numIndexPartitions()) |
| 722 | |
| 723 | params := make(map[string]interface{}, 0) |
| 724 | if startKey != "" { |
| 725 | allDocsQueryStatement = fmt.Sprintf("%s AND META(%s).id >= $startkey", |
| 726 | allDocsQueryStatement, base.KeyspaceQueryAlias) |
| 727 | params[QueryParamStartKey] = startKey |
| 728 | } |
| 729 | if endKey != "" { |
| 730 | allDocsQueryStatement = fmt.Sprintf("%s AND META(%s).id <= $endkey", |
| 731 | allDocsQueryStatement, base.KeyspaceQueryAlias) |
| 732 | params[QueryParamEndKey] = endKey |
| 733 | } |
| 734 | |
| 735 | allDocsQueryStatement = fmt.Sprintf("%s ORDER BY META(%s).id", |
| 736 | allDocsQueryStatement, base.KeyspaceQueryAlias) |
| 737 | |
| 738 | return N1QLQueryWithStats(ctx, c.dataStore, QueryTypeAllDocs, allDocsQueryStatement, params, base.RequestPlus, QueryAllDocs.adhoc, c.dbStats(), c.slowQueryWarningThreshold()) |
| 739 | } |
| 740 | |
| 741 | func (c *DatabaseCollection) QueryTombstones(ctx context.Context, olderThan time.Time, limit int) (sgbucket.QueryResultIterator, error) { |
| 742 |