links: [[Phoenix MOC]]
---
# Simple guide to use Ecto's Repo
## Get One
```elixir
Repo.get(User, 10)
Repo.get_by(User, "
[email protected]") #=> %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
```elixir
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:
- [Ecto Repo](https://hexdocs.pm/ecto/Ecto.Repo.html#c:get/3)
- [Devhints](https://devhints.io/phoenix-ecto)
- [Pin operator Docs](https://hexdocs.pm/ecto/Ecto.Query.html#module-interpolation-and-casting)
- [Pin Operator Forum](https://elixirforum.com/t/ecto-the-pin-operator/1101)