View Source Carbonite.Multi (Carbonite v0.12.1)

This module provides functions for dealing with audit trails in the context of Ecto.Multi.

Summary

Functions

Adds a operation to an Ecto.Multi to fetch the changes of the current transaction.

Sets the current transaction to "override mode" for all tables in the audit log.

Types

Link to this type

params()

View Source (since 0.2.0)
@type params() :: map()
Link to this type

prefix()

View Source (since 0.2.0)
@type prefix() :: binary()
Link to this type

prefix_option()

View Source (since 0.2.0)
@type prefix_option() :: {:carbonite_prefix, prefix()}

Functions

Link to this function

fetch_changes(multi, opts \\ [])

View Source (since 0.5.0)
@spec fetch_changes(Ecto.Multi.t(), [prefix_option()]) :: Ecto.Multi.t()

Adds a operation to an Ecto.Multi to fetch the changes of the current transaction.

Useful for returning all transaction changes to the caller.

Multi step is called :carbonite_changes.

See Carbonite.fetch_changes/2 for options.

Example

Ecto.Multi.new()
|> Carbonite.Multi.insert_transaction(%{meta: %{type: "create_rabbit"}})
|> Ecto.Multi.insert(:rabbit, fn _ -> Rabbit.changeset(%{}) end)
|> Carbonite.Multi.fetch_changes()
Link to this function

insert_transaction(multi, params \\ %{}, opts \\ [])

View Source (since 0.2.0)
@spec insert_transaction(Ecto.Multi.t(), params(), [prefix_option()]) ::
  Ecto.Multi.t()

Adds an insert operation for a Carbonite.Transaction to an Ecto.Multi.

Multi step is called :carbonite_transaction.

See Carbonite.insert_transaction/3 for options.

Example

Ecto.Multi.new()
|> Carbonite.Multi.insert_transaction(%{meta: %{type: "create_rabbit"}})
|> Ecto.Multi.insert(:rabbit, fn _ -> Rabbit.changeset(%{}) end)
Link to this function

override_mode(multi, opts \\ [])

View Source (since 0.2.0)
@spec override_mode(Ecto.Multi.t(), [
  {:to, Carbonite.Trigger.mode()} | prefix_option()
]) ::
  Ecto.Multi.t()

Sets the current transaction to "override mode" for all tables in the audit log.

See Carbonite.override_mode/2 for options.