Remove detour over Enum.into(%{}) for keyword results to %Artikel{}
This commit is contained in:
@ -28,7 +28,7 @@ implement to_param protocol (no more needed for Outlook.Translations.Translation
|
|||||||
where: t.public == true and t.language == ^language,
|
where: t.public == true and t.language == ^language,
|
||||||
order_by: [desc: t.date]
|
order_by: [desc: t.date]
|
||||||
Repo.all(q)
|
Repo.all(q)
|
||||||
|> Enum.map(fn rec -> Enum.into(rec, %{}) end)
|
# |> Enum.map(fn rec -> Enum.into(rec, %{}) end)
|
||||||
|> Enum.map(fn map -> struct(Artikel, map) end)
|
|> Enum.map(fn map -> struct(Artikel, map) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ implement to_param protocol (no more needed for Outlook.Translations.Translation
|
|||||||
where: t.id == ^id and t.public == true
|
where: t.id == ^id and t.public == true
|
||||||
case Repo.one(q) do
|
case Repo.one(q) do
|
||||||
nil -> {:error, "Artikel does not exist, or isn't public."}
|
nil -> {:error, "Artikel does not exist, or isn't public."}
|
||||||
artikel -> {:ok, struct(Artikel, artikel |> Enum.into(%{}))}
|
artikel -> {:ok, struct(Artikel, artikel)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user