ex_audit v0.3.0 ExAudit.Repo behaviour View Source
Replaces Ecto.Repo to be able to keep track of changes made to entities in the repo. Changes made with the following functions are tracked, other function calls must be manually tracked:
insert
,insert!
update
,update!
delete
,delete!
Shared options
All normal Ecto.Repo options will work the same, however, there are additional options specific to ex_audit:
:ex_audit_custom
- Keyword list of custom data that should be placed in new version entries. Entries in this list overwrite the data from the ExAudit.track call:ignore_audit
- If true, ex_audit will not track changes made to entities
Link to this section Summary
Callbacks
Gathers the version history for the given struct, ordered by the time the changes happened from newest to oldest
Undoes the changes made in the given version, as well as all of the following versions
Link to this section Callbacks
history(struct(), opts :: list()) :: [version :: struct()]
Gathers the version history for the given struct, ordered by the time the changes happened from newest to oldest.
Options
:render_structs
if true, renders the resulting struct of the patch for every version in its history. This will shift the ids of the versions one down, so visualisations are correct and corresponding “Revert” buttons revert the struct back to the visualized state. Will append an additional version that contains the oldest ID and the oldest struct known. In most cases, theoriginal
will benil
which means if this version would be reverted, the struct would be deleted.false
by default.
revert(version :: struct(), opts :: list()) :: {:ok, struct()} | {:error, changeset :: Ecto.Changeset.t()}
Undoes the changes made in the given version, as well as all of the following versions.
Inserts a new version entry in the process, with the :rollback
flag set to true
Options
:preload
if your changeset depends on assocs being preloaded on the struct before updating it, you can define a list of assocs to be preloaded with this option