Ecto: Model.get(id) instead of Repo.get(Model, id)

Created on 22 Aug 2015  路  1Comment  路  Source: elixir-ecto/ecto

I'm just thinking if instead of using Repo.get(Game, id) it will be just Game.get(id) ? There are 9 functions. Actually have a module for that, but maybe this can be default behaviour with 'use Ecto.Model' ?

Most helpful comment

The whole point of Ecto is to not couple the Repository with the model. Once you start doing that, all goes downhill. Just call Repo.get/2, you may find it weird initially, specially coming from Rails, but it will really pay off in the long term.

Also, Please use the mailing list or StackOverflow for questions/help, where a wider community will be able to help you. We reserve the issues tracker for issues only.

>All comments

The whole point of Ecto is to not couple the Repository with the model. Once you start doing that, all goes downhill. Just call Repo.get/2, you may find it weird initially, specially coming from Rails, but it will really pay off in the long term.

Also, Please use the mailing list or StackOverflow for questions/help, where a wider community will be able to help you. We reserve the issues tracker for issues only.

Was this page helpful?
0 / 5 - 0 ratings