Carbonite.Query.current_transaction
You're seeing just the function
current_transaction
, go back to Carbonite.Query module for more information.
Specs
current_transaction([current_transaction_option()]) :: Ecto.Query.t()
Returns an Ecto.Query
that can be used to select or delete the "current" transaction.
This function is useful when your tests run in a database transaction using Ecto's SQL sandbox.
Example: Asserting on the current transaction
When you insert your Carbonite.Transaction
record somewhere inside your domain logic, you do
not wish to return it to the caller only to be able to assert on its attributes in tests. This
example shows how you could assert on the metadata inserted.
# Test running inside Ecto's SQL sandbox.
test "my test" do
some_operation_with_a_transaction()
assert current_transaction_meta() == %{"type" => "some_operation"}
end
defp current_transaction_meta do
Carbonite.Query.current_transaction()
|> MyApp.Repo.one!()
|> Map.fetch(:meta)
end
Options
carbonite_prefix
defines the audit trail's schema, defaults to"carbonite_default"
preload
can be used to preload the changes