getQueryAfter()function
getQueryAfter(query: Query<T>, item: T, caller: AnyCaller = getQueryAfter): Query<T>
| Param | Type | |
|---|---|---|
query | Query<T> | The query to page through. It must have an $order. required |
item | T | The item to page from (normally the last item already loaded). required |
caller | AnyCaller | Any calling function or constructor, usually referring to something that can call in the current scope that can appear in a stack trace. Defaults to getQueryAfter |
| Return | |
|---|---|
Query<T> | A new query with the range added. |
| Throws | |
|---|---|
RequiredError | If the query has no $order, or item has no value for the first $order key. |
Get a query for the items that sort at or after a specified item.
- For cursor-based paging towards the end of a result set.
- Adds an inclusive range on the first
$orderkey only (key>=for an ascending order,key<=for a descending order), so items with the same value asitemare included. Drop the items you already have by ID. - Keeps the existing order and limit.
- Page on a first key with many distinct values (e.g. a timestamp). Many items with the same value make each page read them all again.
Examples
getQueryAfter({ $order: "!when" }, { id: "a", when: 5 }) // { $order: "!when", "when<=": 5 }