add list user functions

This commit is contained in:
shibao 2021-09-10 00:19:46 -04:00 committed by oliviasculley
parent 18d69034ff
commit 2291da1c17

View File

@ -59,6 +59,21 @@ defmodule Cannery.Accounts do
""" """
def get_user!(id), do: Repo.get!(User, id) def get_user!(id), do: Repo.get!(User, id)
@spec list_users_by_role(atom()) :: [User.t()]
def list_users_by_role(role) do
Repo.all(from u in User, where: u.role == ^role)
end
@spec list_all_users(boolean()) :: [User.t()]
def list_all_users(confirmed_users_only \\ true) do
if confirmed_users_only do
from u in User, where: u.confirmed_at
else
User
end
|> Repo.all()
end
## User registration ## User registration
@doc """ @doc """