debianize-mobilizon/lib/mobilizon/storage/ecto.ex
2019-09-08 01:49:56 +02:00

16 lines
316 B
Elixir

defmodule Mobilizon.Storage.Ecto do
@moduledoc """
Mobilizon Ecto utils
"""
import Ecto.Query, warn: false
@doc """
Adds sort to the query.
"""
@spec sort(Ecto.Query.t(), atom, atom) :: Ecto.Query.t()
def sort(query, sort, direction) do
from(query, order_by: [{^direction, ^sort}])
end
end