ja_resource v0.3.1 JaResource.Records behaviour

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 JaResource actions:

  • JaResource.Index
  • JaResource.Show
  • JaResource.Update
  • JaResource.Delete

It relies on (and uses):

  • JaResource.Model

Summary

Callbacks

Used to get the base query of records

Callbacks

records(arg0)

Specs

records(Plug.Conn.t) ::
  Plug.Conn.t |
  JaResource.records

Used to get the base query of records.

Many/most controllers 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.Query{}.