FatEcto.Query.FatQueryBuilder (FatEcto v1.1.0)
View SourceThis module builds Ecto queries from a JSON-like structure.
It uses the FatEcto.Dynamics.FatOperatorHelper
module to apply operators and construct the query.
Summary
Functions
Builds an Ecto query from a JSON-like structure.
Functions
@spec build(Ecto.Queryable.t(), map(), keyword()) :: Ecto.Query.t()
Builds an Ecto query from a JSON-like structure.
Examples
iex> import Ecto.Query
...> query = FatEcto.Query.FatQueryBuilder.build(User, %{
...> "$OR" => [
...> %{"name" => "John"},
...> %{"phone" => nil},
...> %{"age" => %{"$GT" => 30}}
...> ]
...> })
iex> inspect(query)
"#Ecto.Query<from u in User, where: u.age > ^30 or (is_nil(u.phone) or u.name == ^"John">"