EctoFilter v0.2.0 EctoFilter.Operators.PatternMatching behaviour 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

Link to this type

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

Link to this type

rule() View Source
rule() :: :like

Link to this section Callbacks

Link to this callback

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