Ecto Extras Hex.pm Hex.pm CI

A set of helper functions for Ecto.Repo and Ecto.Query

Ecto.Repo helpers

first first! last last! count min max avg sum

Setup:

defmodule YourApp.Repo do
use EctoExtras.Repo
# ...
end

Example usage:

Repo.count(User)
# instead of
Repo.one(from u in User, select: count(u.id))

Ecto.Query helpers

lower upper

Example usage:

import EctoExtras.Query
Repo.one(from u in User, where: lower(u.email) == "email@example.com")
# instead of
Repo.one(from u in User, where: fragment("lower(?)", u.email) == "email@example.com")