docs: add a docstring for expr_sort

This commit is contained in:
Zach Daniel 2024-01-12 07:49:46 -05:00
parent 250c4ab8c8
commit db7e42713c

View file

@ -24,6 +24,18 @@ defmodule Ash.Sort do
alias Ash.Error.Query.{InvalidSortOrder, NoSuchAttribute} alias Ash.Error.Query.{InvalidSortOrder, NoSuchAttribute}
@doc """
Builds an expression to be used in a sort statement.
For example:
```elixir
Ash.Query.sort(Ash.Sort.expr_sort(author.full_name))
Ash.Query.sort([{Ash.Sort.expr_sort(author.full_name), :desc_nils_first}])
```
"""
@spec expr_sort(Ash.Expr.t(), Ash.Type.t() | nil) :: Ash.Expr.t()
defmacro expr_sort(expression, type \\ nil) do defmacro expr_sort(expression, type \\ nil) do
quote do quote do
require Ash.Expr require Ash.Expr