Query to compute the set of documents assigned to the specified channel within the sequence range
(ctx context.Context, channelName string, startSeq uint64, endSeq uint64, limit int, activeOnly bool)
| 490 | |
| 491 | // Query to compute the set of documents assigned to the specified channel within the sequence range |
| 492 | func (c *DatabaseCollection) QueryChannels(ctx context.Context, channelName string, startSeq uint64, endSeq uint64, limit int, activeOnly bool) (sgbucket.QueryResultIterator, error) { |
| 493 | |
| 494 | if c.useViews() { |
| 495 | opts := changesViewOptions(channelName, startSeq, endSeq, limit) |
| 496 | return c.dbCtx.ViewQueryWithStats(ctx, c.dataStore, DesignDocSyncGateway(), ViewChannels, opts) |
| 497 | } |
| 498 | |
| 499 | // N1QL Query |
| 500 | // Standard channel index/query doesn't support the star channel. For star channel queries, QueryStarChannel |
| 501 | // (which is backed by IndexAllDocs) is used. The QueryStarChannel result schema is a subset of the |
| 502 | // QueryChannels result schema (removal handling isn't needed for the star channel). |
| 503 | channelQueryStatement, params := c.buildChannelsQuery(channelName, startSeq, endSeq, limit, activeOnly) |
| 504 | return N1QLQueryWithStats(ctx, c.dataStore, QueryChannels.name, channelQueryStatement, params, base.RequestPlus, QueryChannels.adhoc, c.dbStats(), c.slowQueryWarningThreshold()) |
| 505 | } |
| 506 | |
| 507 | // buildsChannelsQuery constructs the query statement and query parameters for a channels N1QL query. Also used by unit tests to validate |
| 508 | // query is covering. |