Reputation: 1918
Trying to compose a query (finding all users created more than 30 days ago) that corresponds to the following psql query:
SELECT * FROM users
WHERE date_part('day', now()-inserted_at) > 30;
Upvotes: 1
Views: 126
Reputation: 11278
from u in User, where: u.inserted_at > ago(30, "days")
https://hexdocs.pm/ecto/Ecto.Query.API.html#ago/2
Upvotes: 6