ExTeal.Resource.Records behaviour (ExTeal v0.21.0) View Source

Provides the records/1 callback used for querying records to be served.

This is typically the base query that you expose, often scoped to the current user.

This behaviour is used by the following ExTeal.Resource actions:

  • ExTeal.Resource.Index
  • ExTeal.Resource.Show
  • ExTeal.Resource.Update
  • ExTeal.Resource.Delete

It relies on (and uses):

  • ExTeal.Resource.Model

Link to this section Summary

Callbacks

Used to get the base query of records.

Used to specify which relationships to always preload with all requests.

Link to this section Callbacks

Specs

Used to get the base query of records.

Many/most resources will override this:

def records(%Plug.Conn{assigns: %{user_id: user_id}}) do
  model()
  |> where([p], p.author_id == ^user_id)
end

Return value should be %Plug.Conn{} or an %Ecto.Queryable{}.

Specs

with() :: [atom()]

Used to specify which relationships to always preload with all requests.

Link to this section Functions