FatEcto.Query.Builder (FatEcto v1.3.0)
View SourceBuilds Ecto queries from a structured query map. Used by FatQueryBuildable for query building with query callbacks.
Summary
Functions
Builds an Ecto query from a structured query map with dynamic conditions.
Functions
@spec build(Ecto.Queryable.t(), map(), function() | nil, list() | nil) :: Ecto.Query.t()
Builds an Ecto query from a structured query map with dynamic conditions.
This function processes query maps that can contain field-specific conditions
as well as logical operators ($AND, $OR) to build complex queries.
Parameters
queryable- The Ecto queryable (schema or query) to build uponquery_map- A map containing query conditions and operatorsoverride_callback- Optional function to handle custom field processingoverrideable_fields- List of field names that can use the override callback
Query Map Format
The query map can contain:
- Field names as keys with condition maps as values
$ANDkey with a list of condition maps for AND logic$ORkey with a list of condition maps for OR logic
Examples
# Simple field condition
query_map = %{"name" => %{"$LIKE" => "%John%"}}
Builder.build(User, query_map)
# Complex query with OR logic
query_map = %{
"$OR" => [
%{"name" => %{"$LIKE" => "%John%"}},
%{"email" => %{"$LIKE" => "%@gmail.com"}}
]
}
Builder.build(User, query_map)Returns
An Ecto.Query.t() with the conditions applied.