FatEcto.Dynamics.FatDynamicsBuilder (FatEcto v1.1.0)

View Source

This module builds Ecto dynamic 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 dynamic query from a JSON-like structure.

Functions

build(query_map, opts \\ [], override_callback \\ nil)

@spec build(map(), keyword(), function() | nil) :: Ecto.Query.dynamic_expr()

Builds an Ecto dynamic query from a JSON-like structure.

Examples

iex> import Ecto.Query
...> query = FatEcto.Dynamics.FatDynamicsBuilder.build(%{
...>   "$OR" => [
...>     %{"name" => "John"},
...>     %{"phone" => nil},
...>     %{"age" => %{"$GT" => 30}}
...>   ]
...> })
iex> inspect(query)
"dynamic([q], q.name == ^\"John\" or is_nil(q.phone) or q.age > ^30)"