FatEcto.Pagination.Helper (FatEcto v1.2.0)

View Source

Provides utility functions for FatEcto, including handling pagination limits, skip values, dynamic binding, and preloading associations.

Summary

Functions

Returns the maximum and default limit values based on the provided options.

Extracts and validates the limit value from the given parameters.

Extracts and validates the skip value from the given parameters.

Functions

get_limit_bounds(options)

@spec get_limit_bounds(nil | keyword() | map()) :: {integer(), integer()}

Returns the maximum and default limit values based on the provided options.

Parameters

  • options: A keyword list or map containing max_limit and default_limit.

Examples

iex> FatEcto.Pagination.Helper.get_limit_bounds(max_limit: 50, default_limit: 10)
{50, 10}

get_limit_value(params, options \\ [])

@spec get_limit_value(
  keyword(),
  nil | keyword() | map()
) :: {integer(), keyword()}

Extracts and validates the limit value from the given parameters.

Parameters

  • params: A keyword list containing the :limit value.
  • options: A keyword list or map containing max_limit and default_limit.

Examples

iex> FatEcto.Pagination.Helper.get_limit_value([limit: 15], max_limit: 50, default_limit: 10)
{15, []}

get_skip_value(params)

@spec get_skip_value(keyword()) :: {integer(), keyword()}

Extracts and validates the skip value from the given parameters.

Parameters

  • params: A keyword list containing the :skip value.

Examples

iex> FatEcto.Pagination.Helper.get_skip_value(skip: 20)
{20, []}