add seeding of db
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user