-
-
Save shankardevy/66fccc088b420d684f073e8ec7ea1473 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 | |
alias Mango.Catalog.Product | |
alias Mango.Repo | |
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