View Source Bonfire.Common.Repo.Delete (Bonfire v0.9.10-classic-beta.169)
Helpers for deleting Ecto data
Summary
Functions
Actually deletes an entry from the database.
Actually deletes an entry from the database, or throws an error.
Marks an entry as deleted in the database.
Marks an entry as deleted in the database or throws an error.
Creates a changeset for marking an entity as deleted.
Marks an entry as not deleted.
Functions
Actually deletes an entry from the database.
Examples
iex> hard_delete(some_entry)
{:ok, some_entry}
iex> hard_delete(non_existent_entry)
{:error, :deletion_error}
Actually deletes an entry from the database, or throws an error.
Examples
iex> hard_delete!(some_entry)
some_entry
iex> hard_delete!(non_existent_entry)
** (RuntimeError) :deletion_error
Marks an entry as deleted in the database.
Examples
iex> soft_delete(some_entry)
{:ok, some_entry}
iex> soft_delete(non_existent_entry)
{:error, :deletion_error}
Marks an entry as deleted in the database or throws an error.
Examples
iex> soft_delete!(some_entry)
some_entry
iex> soft_delete!(non_existent_entry)
** (RuntimeError) :deletion_error
Link to this function
soft_delete_changeset(it, column \\ :deleted_at, value \\ DateTime.utc_now(), error \\ "was already deleted")
View SourceCreates a changeset for marking an entity as deleted.
Examples
iex> soft_delete_changeset(some_entry)
%Ecto.Changeset{...}
iex> soft_delete_changeset({SomeSchema, some_entry}, :deleted_at, nil, "was already deleted")
%Ecto.Changeset{...}
Marks an entry as not deleted.
Examples
iex> undelete(some_entry)
{:ok, some_entry}
iex> undelete(non_existent_entry)
{:error, :deletion_error}