Updating a field using Ecto one-liner?

Ecto has made the decision to clearly separate data from action, whereas in an OO language like Ruby they’re tied together.

Consequently, you may need an extra line or two to do certain things via Ecto that you’d do from ActiveRecord. I don’t really see this as much of a problem, and it helps make it wildly clearer when and how database access actually happens.

Normal aliasing practices will also help a bit alias MyApp.Repo.

Ultimately though I’m not really sure what your question is. You ask “how” but then you provide an example that does exactly what you want. Is your question more “what’s the most succinct way I can do this?” ?

2 Likes