vt-elixir / ja_resource

A behaviour to reduce boilerplate code in your JSON-API compliant Phoenix controllers without sacrificing flexibility.
Other
113 stars 33 forks source link

Callback for querying repo (eg for scrivener integration). #5

Closed alanpeabody closed 8 years ago

alanpeabody commented 8 years ago

I am thinking:

@callback handle_query(%Plug.Conn, JaResource.queryable, String.t) :: list(JaResource.record)

Where third argument is :show or :index.

Default implementation would be something like:

def handle_query(_conn, query, :show), do: repo().one(query)
def handle_query(_conn, query, :index), do: repo().all(query)