add seeding of db

This commit is contained in:
2021-07-01 13:03:34 +02:00
parent 176707ed4b
commit 68462b7cb7
3 changed files with 67 additions and 1 deletions
+10
View File
@@ -12,5 +12,15 @@
alias PokemonCouture.Repo
alias PokemonCouture.Shops.Clothes
defmodule Parser do
def parse do
File.stream!("sunmoon_clothes.csv")
|> CSV.decode!(headers: :true)
# |> Enum.each(fn x -> IO.inspect(x) end)
|> Enum.map(fn x -> %Clothes{game: x["game"], location: x["location"], name: x["name"], color: x["color"]} end)
|> Enum.each(fn x -> Repo.insert!(x) end)
end
end
Repo.insert! %Clothes{game: "Tlapka", location: "Tlapkov", name: "Tlapka Hat", color: "Blue"}
Parser.parse()