Mongo.Repo.transaction

You're seeing just the callback transaction, go back to Mongo.Repo module for more information.

Specs

transaction(fun :: (... -> {:ok, any()} | :error), opts :: Keyword.t()) ::
  {:ok, any()} | :error | {:error, any()}

Convenient function for running multiple write commands in a transaction.

In case of TransientTransactionError or UnknownTransactionCommitResult the function will retry the whole transaction or the commit of the transaction. You can specify a timeout (:transaction_retry_timeout_s) to limit the time of repeating. The default value is 120 seconds. If you don't wait so long, you call transaction with the option transaction_retry_timeout_s: 10. In this case after 10 seconds of retrying, the function will return an error.

You can nest the function calls. In this case the first session will be reused.