Ecto Query Helpers

I figure many of the newer guys here could benefit from this. A while back I wrote an Ecto helper that makes queries in iex quite a bit easier.

Use it by adding the following at the top of your model:

use Repo.Helpers, repo: YourApp.Repo

For a model like User, this would enable the following example queries:

User.all
User.get(id)
User.get(id, :posts) # fetches user with `id` and `posts` preloaded
User.get_by(username: "person")
User.where(is_activated: true)

Suggestions and critiques welcome. I’m sure someone has some macro sorcery to contribute.