Ecto Filters v0.1.0 EctoFilters behaviour View Source

Adds function to transform request params into ecto query expressions.

Link to this section Summary

Callbacks

Applies filters to a queryable. Accepts a Ecto.Queryable and a map of with the "q" string key and returns a Ecto.Queryable.

Link to this section Callbacks

Link to this callback

apply_filters(queryable, params) View Source
apply_filters(queryable :: Ecto.Queryable.t(), params :: %{}) ::
  Ecto.Queryable.t()

Applies filters to a queryable. Accepts a Ecto.Queryable and a map of with the "q" string key and returns a Ecto.Queryable.

Examples

iex> apply_filters(Post, %{"q" => %{"title" => "Ecto Filters"}}) |> MyRepo.all()
[%Post{title: "Ecto Filters"}, ...]