Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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)...


It 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.


Exactly the same:

  Repo.get_by(Post, title: "My post")
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)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: