OuterfacesEctoApi.QueryEngine.QueryPager (Outerfaces Ecto API v0.2.8)

View Source

Summary

Functions

Applies ordering, limit, and offset to a given query.

Types

pagination_info()

@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()
}

Functions

apply_paging(query, params)

@spec apply_paging(Ecto.Query.t(), map()) :: Ecto.Query.t()

Applies ordering, limit, and offset to a given query.

Parameters:

  • query: The Ecto query.
  • params: A map containing "limit", and "offset".

Example usage: QueryPager.apply_paging(query, %{"limit" => 10, "offset" => 20})

compute_pagination(params, total_count)

@spec compute_pagination(map(), non_neg_integer()) :: pagination_info()