Ecto.Changeset.fetch_field
You're seeing just the function
fetch_field
, go back to Ecto.Changeset module for more information.
Specs
Fetches the given field from changes or from the data.
While fetch_change/2
only looks at the current changes
to retrieve a value, this function looks at the changes and
then falls back on the data, finally returning :error
if
no value is available.
For relations, these functions will return the changeset
original data with changes applied. To retrieve raw changesets,
please use fetch_change/2
.
Examples
iex> post = %Post{title: "Foo", body: "Bar baz bong"}
iex> changeset = change(post, %{title: "New title"})
iex> fetch_field(changeset, :title)
{:changes, "New title"}
iex> fetch_field(changeset, :body)
{:data, "Bar baz bong"}
iex> fetch_field(changeset, :not_a_field)
:error