3 ms·
I don't see how Ecto is any worser than AR - imo it is not AND way more flexible. Also, `from ...` form is not the best choice - other form (e.g. user = User
by out_of_protocol 9y ago
I don't see how Ecto is any worser than AR - imo it is not AND way more flexible. Also, `from ...` form is not the best choice - other form (e.g.
user = User |> User.actual |> User.by_email(email) |> ....
) allows query decomposition, the same way AR does.
user = User.actual.by_email(email)...
- pmontra 9y agoIt is more flexible, but often that flexibility is not necessary. I replied in more detail to the sibling answer but in the Ecto version of this sample query, don't I have to write the definition of actual and by_email? AR gives me by_email for free. Instead, actual would be a scope and I have to write that code with AR too.
- out_of_protocol 9y agoExactly the same: Repo.get_by(Post, title: "My post") https://hexdocs.pm/ecto/Ecto.Repo.html#c:get_by/3 https://hexdocs.pm/ecto/Ecto.Repo.html#c:get_by/3 (Rails/AR deprecated find_by_xxx methods, promotes find_by() instead - for performance reasons)