I am getting project permissions access level and accessing it through Enum.map(). I want to put a check if it is "Owner" how do I do that from a map. How do I do that
project_permissions = ProjectPermissions.list_project_permissions()
Enum.map(project_permissions, fn %{id: id, access_level: access_level} ->
{access_level, id} |> IO.inspect()
end)
or instead of pulling a list of all records from the database and finding the one you want, you can more efficiently query the one record you want directly from the database
def get_project_permission_by_access_level(access_level) do
Repo.get_by(ProjectPermission, access_level: access_level)
end
get_project_permission_by_access_level("Owner")