Skip to content

Instantly share code, notes, and snippets.

@motephyr
Last active August 10, 2017 10:54
Show Gist options
  • Save motephyr/40b5e3f41aa3fb8d53b053de32aa1c7f to your computer and use it in GitHub Desktop.
Save motephyr/40b5e3f41aa3fb8d53b053de32aa1c7f to your computer and use it in GitHub Desktop.
import Ecto.Query
alias YourApp.Repo
alias YourApp.User
#(這也許是一個改名字的流程)
#你要query user.id = 1的人
#抓到這個人之後
#改他的名字
#更新
result = from(u in User, where: u.id == 1) #Ecto.Query
|> Repo.one #Ecto.Schema
|> User.changeset(%{name: "abc"}) #Ecto.changeset
|> Repo.update() #Ecto.Repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment