-
-
Save shankardevy/b9412937106ac7526898eff99718c87b to your computer and use it in GitHub Desktop.
This file contains 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
defmodule Mango.Catalog do | |
@moduledoc """ | |
API boundary for the Catalog system. | |
""" | |
alias Mango.Catalog.Product | |
alias Mango.Repo | |
def get_product!(id), do: Product |> Repo.get!(id) | |
def list_products do | |
Product | |
|> Repo.all | |
end | |
def list_seasonal_products do | |
list_products() | |
|> Enum.filter(fn(product) -> product.is_seasonal == true end) | |
end | |
def get_category_products(name) do | |
list_products() | |
|> Enum.filter(fn(product) -> product.category == name end) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment