HawkEx.Pagination (hawk_ex v0.1.0)

Copy Markdown View Source

Shared offset-based pagination helper.

This module is used by HawkEx.Audit, HawkEx.Billing, and HawkEx.CSV to keep dashboard-style pagination consistent. Host applications should usually call the pagination functions on those context modules instead of calling this module directly.

Summary

Functions

Paginates a base Ecto query.

Functions

paginate(base_query, opts \\ [])

Paginates a base Ecto query.

Options

  • :page - 1-indexed page number. Defaults to 1.
  • :per_page - rows per page. Defaults to 50.
  • :search - optional search term.
  • :search_fun - (query, search_term) -> query, applied only when :search is present and non-empty. Required if search may be passed.
  • :order_by - keyword list passed to Ecto's order_by. Defaults to [desc: :inserted_at].
  • :preload - value passed to Ecto's preload. Defaults to [].

Returns %{entries:, page:, per_page:, total_count:, total_pages:}.