Add a function to lookup client app details by the app_id

This commit is contained in:
Mark Felder 2021-02-09 14:41:58 -06:00
parent fc42e714e2
commit de8b8e9cf1

View file

@ -146,4 +146,14 @@ def errors(changeset) do
Map.put(acc, key, error) Map.put(acc, key, error)
end) end)
end end
@spec get_app_by_id(pos_integer()) :: {:ok, map()}
def get_app_by_id(app_id) do
query =
__MODULE__
|> where([a], a.id == ^app_id)
|> select([a], %{name: a.client_name, website: a.website})
Repo.one!(query)
end
end end