EctoFilter.Operators.PatternMatching behaviour (EctoFilter v0.3.1) View Source

Pattern matching operators.

Examples:

With "LIKE" condition

iex> Repo.insert!(%User{first_name: "Bob"})
iex> Repo.insert!(%User{first_name: "Alice"})
iex> result =
...>   User
...>   |> EctoFilter.filter([{:first_name, :like, "al"}])
...>   |> Repo.all()
iex> length(result)
1
iex> hd(result).first_name
"Alice"

Link to this section Summary

Link to this section Types

Specs

condition() :: {field :: atom(), rule :: rule(), value :: any()}

Specs

rule() :: :like

Link to this section Callbacks

Link to this callback

apply(query, condition, type, context)

View Source

Specs

apply(
  query :: Ecto.Query.t(),
  condition :: condition(),
  type :: EctoFilter.field_type(),
  context :: Ecto.Queriable.t()
) :: Ecto.Query.t()