The options that Dogbert has provided are both correct and should be used for Ecto 1.x.
In Ecto 2.0 you can use Repo.aggregate/4
Repo.aggregate(Post, :count, :id)
The options that Dogbert has provided are both correct and should be used for Ecto 1.x.
In Ecto 2.0 you can use Repo.aggregate/4
Repo.aggregate(Post, :count, :id)