Trash.Test.Repo.discard
You're seeing just the function
discard
, go back to Trash.Test.Repo module for more information.
Link to this function
discard(changeset)
Specs
discard(changeset_or_schema :: Ecto.Changeset.t() | Ecto.Schema.t()) :: {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
Updates a record as discarded.
This takes either an Ecto.Changeset
or an Ecto.Schema
struct. If a
struct is given a bare changeset is generated first.
A change is added to the changeset to set discarded_at
to
DateTime.utc_now/1
. It calls repo.update/2
to finalize the changes.
It returns {:ok, struct}
if the struct has been successfully updated
or {:error, changeset}
if there was an error.
Examples
iex> Post.changeset(post, %{title: "[Archived] Hello, world"})
|> MyRepo.discard()
{:ok,
%Post{title: "[Archived] Hello, world", discarded_at: %DateTime{}}}