iex> book = %{book | description: "Programming Elixir: a lot more fun", \
title: "Programming Elixir with fun"}
%BookStore.Books{author: "Dave Thomas",
description: "Programming Elixir: a lot more fun", id: 1,
publisher: "The Pragmatic Bookshelf", title: "Programming Elixir with fun"}
iex> Repo.update(book)
:ok
iex> Repo.get(Books, 1)
%BookStore.Books{author: "Dave Thomas",
description: "Programming Elixir: a lot more fun", id: 1,
publisher: "The Pragmatic Bookshelf", title: "Programming Elixir with fun"}
插入
1
iex> Repo.insert(%Books{author: "Simon St. Laurent, J. David Eisenberg", \
description: "Elixir is an excellent language if you want to \
learn about functional programming, and with this hands-on \
introduction",
publisher: "O'Reilly", title: "Introducing Elixir"})
%BookStore.Books{author: "Simon St. Laurent, J. David Eisenberg",
description: "Elixir is an excellent language if you want to learn about \
functional programming, and with this hands-on introduction", \
id: 18, publisher: "O'Reilly", title: "Introducing Elixir"}
删除
1
iex> introducing_elixir_book = Repo.get(Books, 2)
%BookStore.Books{author: "Simon St. Laurent, J. David Eisenberg",
description: "Elixir is an excellent language if you want to learn \
about functional programming, and with this hands-on introduction",
id: 2, publisher: "O'Reilly", title: "Introducing Elixir"}
iex> Repo.delete(introducing_elixir_book)
:ok