OuterfacesEctoApi.QueryEngine.QueryPager (Outerfaces Ecto API v0.2.9)
View SourceLimit and offset from the request's query param, and the page_info that
describes them. paging/2 works out the limit and offset once, so the rows
returned and the page_info reported always agree.
Summary
Types
@type pagination_info() :: %{ total_count: non_neg_integer(), total_pages: pos_integer(), has_next_page: boolean(), has_previous_page: boolean(), limit: non_neg_integer(), offset: non_neg_integer() }
@type paging() :: %{limit: non_neg_integer() | nil, offset: non_neg_integer()}
Functions
@spec apply(Ecto.Query.t(), paging()) :: Ecto.Query.t()
Applies a paging/2 result to query.
@spec apply_paging(Ecto.Query.t(), map()) :: Ecto.Query.t()
Applies limit and offset to a given query.
QueryPager.apply_paging(query, %{"query" => ~s({"limit": 10, "offset": 20})})
@spec compute_pagination(map(), non_neg_integer()) :: pagination_info()
@spec page_info(paging(), non_neg_integer()) :: pagination_info()
The page_info for a paging/2 result and the total row count.
The limit and offset to apply. Integers or integer strings are accepted.
Options: :default_limit (when none is sent) and :max_limit (the largest
allowed). Without either, a request that sends no limit gets every row.