Karta. Pager
(Karta v1.0.0)
Long lists in pages, by keyset rather than by offset: a page is named by the id of the row next to it (a cursor), so that it stays where it is when rows are added in front of it, and reading a page costs the same at any depth.
The rows are ordered by one field and then by id, both in the same
direction: order: {:desc, :created_at} is newest first, {:asc, :name}
by name. after: id asks for the rows that come after the row id in
that order, before: id for the rows that come before it.
A cursor is only ever an id. It is cast with Ecto.UUID.cast/1 and looked
up in the query given, so a cursor that is not a UUID, or that names a
row the query does not select (another server's message, an organisation
the user does not belong to), gives the first page.
Summary
Functions
A page of query's rows. Options: order (required, see the module
doc), limit (default 50), and after or before (an
id; anything else is the first page). query must not be ordered or
limited already.
Functions
@spec page(Ecto.Queryable.t(), keyword()) :: Karta.Pager.Page.t()
A page of query's rows. Options: order (required, see the module
doc), limit (default 50), and after or before (an
id; anything else is the first page). query must not be ordered or
limited already.