defmodule Wild.Books.Book do
  use Ecto.Schema
  import Ecto.Changeset

  schema "books" do
    field :title, :string
    field :blurb, :string
    field :publication_year, :string

    belongs_to :author, Wild.Books.Author
    # field :author_id, :id

    timestamps(type: :utc_datetime)
  end

  @doc false
  def changeset(book, attrs) do
    book
    |> cast(attrs, [:title, :blurb, :publication_year])
    |> validate_required([:title, :blurb, :publication_year])
  end
end
