Skip to content

Commit

Permalink
adds ecto Query Prefix functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
redmar committed Jan 30, 2020
1 parent 9486132 commit 134e517
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/turbo_ecto.ex
Expand Up @@ -99,9 +99,11 @@ defmodule Turbo.Ecto do
defp get_paginate(queryable, params, opts), do: Paginate.get_paginate(queryable, params, opts)

defp handle_query(queryable, opts) do
prefix = Keyword.get(opts, :prefix)

case Keyword.get(opts, :repo) do
nil -> raise "Expected key `repo` in `opts`, got #{inspect(opts)}"
repo -> apply(repo, :all, [queryable])
repo -> apply(repo, :all, [queryable |> Map.put(:prefix, prefix)])
end
end
end

0 comments on commit 134e517

Please sign in to comment.