Closed d-mart closed 7 years ago
How would a phoenix action look like for this interface?
How would a phoenix action look like for this interface?
Something like this (generic/psuedo code, but adapted from a real use)
def update(%{method: "PATCH"} = conn, %{"_json" => change_list, "id" => id}) do
my_thing = Repo.Thing.get(id) # generic Ecto.Repo lookup
updated_thing = my_thing
|> Map.from_struct
|> ThingTranscoder.patch!(change_list)
case Repo.Thing.changeset(my_thing, updated_thing) |> Repo.update! do
{:error, error} -> # use conn to return error
{:ok, _} -> # use conn to return 204
end
end
released as 5.2.1
thanks!
Awesome, thanks!
🔜 Will update docs if the API looks okprotected: true
option in the transcoder