Drops.Relation.Query (drops_relation v0.1.0)
View SourceProvides query composition macros for building complex relation queries.
This module contains macros for transforming query expressions and enabling composition of relation operations. It supports logical operations (AND/OR) and function call transformations within query contexts.
Usage
defmodule Users do
use Drops.Relation, repo: MyApp.Repo
schema("users", infer: true)
defquery active(), do: from(u in relation(), where: u.active == true)
defquery by_role(role), do: from(u in relation(), where: u.role == ^role)
end
query(Users, [u], u.active() and u.by_role("admin"))
Supported Operations
and
- Logical AND compositionor
- Logical OR composition- Function calls on relation bindings
The macro transforms expressions to use the appropriate relation operations and maintains proper binding contexts for complex queries.