View Source Indexed.Helpers (Indexed v0.0.1)

Helper functions for internal use.

Link to this section Summary

Functions

Get the id of the record being operated on from an action state.

Get the id of the record being operated on.

Convert a field-only order hint into a tuple one.

Convert a preload shorthand into a predictable data structure.

Link to this section Functions

@spec id(map()) :: any()

Get the id of the record being operated on from an action state.

See id_value/2.

@spec id(map(), any()) :: any()

Get the id of the record being operated on.

See Indexed.Entity.t/0.

Link to this function

normalize_order_hint(hint)

View Source
@spec normalize_order_hint(Indexed.order_hint()) :: [{:asc | :desc, atom()}]

Convert a field-only order hint into a tuple one.

Link to this function

normalize_preload(preload)

View Source
@spec normalize_preload(atom() | list()) :: [tuple()]

Convert a preload shorthand into a predictable data structure.

examples

Examples

iex> normalize_preload(:foo)
[foo: []]
iex> normalize_preload([:foo, bar: :baz])
[foo: [], bar: [baz: []]]