ElixirWeekly: The Elixir Community Newsletter, covering community news you easily miss, shared on ElixirStatus and the web, in one email every Thursday.
Db.Repo.all(from c in Comment, where: c.post_id == ^post_id)
Ecto has always seemed more verbose, and harder to read than it needs to be. I’d rather write:
Don’t want to write CRUD for every model? Let BaseModel write it for you: add
use BaseModel, repo: MyApp.Repo to the top of your models, and immediately gain a fluent API for your data:
count(where_clause \\ )
BaseModel resolves associations automatically, supports Ecto validations, saves lots of keystrokes on the console while developing and debugging, and encourages good separation of persistence code from the rest of your app.
Check it out on Github.