mobilizon.chapril.org-mobil.../lib/mobilizon/storage/ecto.ex

16 lines
316 B
Elixir
Raw Normal View History

2019-09-08 01:49:56 +02:00
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