links: Phoenix MOC
Simple guide to use Ecto’s Repo
Get One
Repo.get(User, 10)
Repo.get_by(User, "subramanya@fyndx.io") #=> %User{}| nil
Repo.one(from u in User, where u.email == ^email)The pin operator (^)
The pin operator is specific to Ecto which is necessary for accessing database
u = %User{id: 1, age: 26}
query = from u in User, where u.age > ^u.age
Repo.all(query)In the above example the right side of where ^u.age the u refers to the user
tags: database
sources: