Created
March 20, 2022 00:13
-
-
Save danhawkins/c266904a558f2422cd7bfe0448dd48ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def list_groups(region \\ nil, search \\ nil) do | |
| query = | |
| from(g in Group) | |
| |> filter_region(region) | |
| query |> Repo.all() | |
| end | |
| defp filter_region(query, nil), do: query | |
| defp filter_region(query, region) do | |
| from(g in query, where: g.region == ^region) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment