View Source Lightning.Auditing.Audit behaviour (Lightning v2.10.4)
Macro module to add common model behaviour to a given Ecto model
Summary
Callbacks
Callback to update changes before saving to the database.
Functions
Creates a changeset
for the event
identified by item_id
and caused
by actor
.
Saves the event to the Repo
.
Callbacks
Callback to update changes before saving to the database.
Functions
event(item_type, event, item_id, actor, changes \\ %{}, metadata \\ %{}, update_fun \\ fn x -> x end)
View Source@spec event( String.t(), String.t(), Ecto.UUID.t(), Lightning.Accounts.User.t() | Lightning.VersionControl.ProjectRepoConnection.t() | Lightning.Workflows.Trigger.t(), Ecto.Changeset.t() | map() | nil, map(), update_changes_fun :: (map() -> map()) ) :: :no_changes | Ecto.Changeset.t()
Creates a changeset
for the event
identified by item_id
and caused
by actor
.
The given changes
can be either nil
, Ecto.Changeset
, struct or map.
It returns :no_changes
in case of an Ecto.Changeset
changes that changed nothing
or an Ecto.Changeset
with the event ready to be inserted.
@spec save(Ecto.Changeset.t() | :no_changes, Ecto.Repo.t()) :: {:ok, :no_changes} | {:ok, Ecto.Schema.t()} | {:error, Ecto.Changeset.t()}
Saves the event to the Repo
.
In case of nothing changes, do nothing.
It returns {:ok, :no_changes}
if nothing changed, {:ok, struct}
if the log
has been successfully saved or {:error, changeset}
in case of error.