Ecto Commands
April 15, 2022 1 minutes • 38 words
post = MyRepo.get!(Post, 42)
post = Ecto.Changeset.change post, title: "New title"
case MyRepo.update post do
{:ok, struct} -> # Updated with success
{:error, changeset} -> # Something went wrong
end
Repo.get_by(Chat, id: chat_id)
|> Ecto.Changeset.change(%{visible: true})
|> Repo.update()