Mongo.Session (Mongodb v1.0.0) View Source

Link to this section Summary

Functions

Abort current transaction and rollback changes introduced by it. It will error if the session is invalid.

Commit current transaction. It will error if the session is in invalid state.

Finish current session and rollback uncommited transactions if any.

Check whether given session has already ended.

Start new transaction within current session.

Run provided func within transaction and automatically commit it if there was no exceptions.

Link to this section Types

Specs

session()

Link to this section Functions

Specs

abort_transaction(session()) :: :ok | {:error, term()}

Abort current transaction and rollback changes introduced by it. It will error if the session is invalid.

Specs

commit_transaction(session()) :: :ok | {:error, term()}

Commit current transaction. It will error if the session is in invalid state.

Specs

end_session(session()) :: :ok

Finish current session and rollback uncommited transactions if any.

WARNING: Session is ended in asynchronous manner, which mean, that the process itself can be still available and Mongo.Session.ended?(session) can still return false for some time after calling this function.

Specs

ended?(session()) :: boolean()

Check whether given session has already ended.

Link to this function

start_transaction(pid, opts \\ [])

View Source

Specs

start_transaction(session(), keyword()) :: :ok | {:error, term()}

Start new transaction within current session.

Link to this function

with_transaction(pid, opts \\ [], func)

View Source

Specs

with_transaction(session(), keyword(), (() -> return)) ::
  {:ok, return} | {:error, term()}
when return: term()

Run provided func within transaction and automatically commit it if there was no exceptions.