Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Last active August 18, 2017 06:26
Show Gist options
  • Save shankardevy/66fccc088b420d684f073e8ec7ea1473 to your computer and use it in GitHub Desktop.
Save shankardevy/66fccc088b420d684f073e8ec7ea1473 to your computer and use it in GitHub Desktop.
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