Updating a field using Ecto one-liner?

you can do:

Ecto.Changeset.change( MyApp.Repo.get_by(MyApp.User, email: "foobar@email.com"), %{email: "hello@email.com"}) |> MyApp.Repo.update()

but piping is much nicer:

MyApp.Repo.get_by(MyApp.User, email: "foobar@email.com")
|> Ecto.Changeset.change(%{email: "hello@email.com"})
|> MyApp.Repo.update()

I would not do this for production code though - I would have error handling, and explicit changeset with the needed validations etc etc.