mirror of
https://github.com/ash-project/ash.git
synced 2024-09-20 05:23:03 +12:00
improvement: add where
and or_where
to expr
This commit is contained in:
parent
c45acafd17
commit
9047fbd2ee
1 changed files with 18 additions and 0 deletions
|
@ -4,6 +4,24 @@ defmodule Ash.Expr do
|
|||
|
||||
@type t :: any
|
||||
|
||||
defmacro where(left, right) do
|
||||
left = do_expr(left)
|
||||
right = do_expr(right)
|
||||
|
||||
quote do
|
||||
Ash.Expr.expr(unquote(left) and unquote(right))
|
||||
end
|
||||
end
|
||||
|
||||
defmacro or_where(left, right) do
|
||||
left = do_expr(left)
|
||||
right = do_expr(right)
|
||||
|
||||
quote do
|
||||
Ash.Expr.expr(unquote(left) or unquote(right))
|
||||
end
|
||||
end
|
||||
|
||||
defmacro expr(do: body) do
|
||||
quote location: :keep do
|
||||
Ash.Expr.expr(unquote(body))
|
||||
|
|
Loading…
Reference in a new issue