Incant.Ecto (Incant v0.1.1)

Copy Markdown View Source

Small Ecto helpers for application-owned Incant resource queries.

Applications retain ownership of filtering, joins, projections, and authorization. These helpers only apply normalized table sorting and exact offset pagination.

Summary

Functions

Counts, clamps, and applies exact offset pagination to a query.

Applies an allowlisted table sort with a deterministic tie-breaker.

Types

page()

@type page() :: %{
  page: pos_integer(),
  page_size: pos_integer(),
  total: non_neg_integer(),
  total_pages: pos_integer()
}

Functions

page(queryable, repo, table_state)

@spec page(Ecto.Queryable.t(), module(), map()) :: {Ecto.Query.t(), page()}

Counts, clamps, and applies exact offset pagination to a query.

sort(queryable, table_state, allowed_fields, opts \\ [])

@spec sort(Ecto.Queryable.t(), map(), [atom()], keyword()) :: Ecto.Query.t()

Applies an allowlisted table sort with a deterministic tie-breaker.