View on GitHub
ejpp
Embedded JSON Database engine for C++11/14
Public Member Functions | Friends | List of all members
ejdb::collection::transaction_t Struct Reference

Represents an EJDB transaction. More...

#include <ejdb.hpp>

Public Member Functions

bool abort () noexcept
 Aborts a transaction. More...
 
bool commit () noexcept
 Commits a transaction. More...
 
bool in_transaction () const noexcept
 Returns whether a transaction is in progress. More...
 
 operator bool () const noexcept
 Returns whether a transaction is in progress. More...
 
bool start () noexcept
 Starts a transaction. More...
 

Friends

struct collection
 
struct unique_transaction
 

Detailed Description

Represents an EJDB transaction.

A transaction is a series of operations that will either be completed all at once or not at all.

A collection cannot have more than one transaction at a time. A transaction must be committed or aborted before another can start. Transactions cannot be nested.

A transaction has no effect on the lifetimes of a parent db or collection object, only references to a transaction_t can be obtained by users.

Although none of the member functions throw, it is not exception-safe to use this class directly for transaction functionality.

Member Function Documentation

bool ejdb::collection::transaction_t::abort ( )
noexcept

Aborts a transaction.

Abandons all changes made to the associated collection after a call to transaction_t::start.

Parent db object may have a related error code (via db::error) on failure.

Returns
true on success, false on failure.
bool ejdb::collection::transaction_t::commit ( )
noexcept

Commits a transaction.

Commits all changes made to the associated collection after a call to transaction_t::start.

Parent db object may have a related error code (via db::error) on failure.

Returns
true on success, false on failure.
bool ejdb::collection::transaction_t::in_transaction ( ) const
noexcept

Returns whether a transaction is in progress.

Returns
true when parent db is alive, open, and the transaction is in progress, i.e. started, but neither committed nor aborted.
ejdb::collection::transaction_t::operator bool ( ) const
explicitnoexcept

Returns whether a transaction is in progress.

Returns
true when parent db is alive, open, and the transaction is in progress, i.e. started, but neither committed nor aborted.
bool ejdb::collection::transaction_t::start ( )
noexcept

Starts a transaction.

Any operation performed on the associated collection after a successful call will be part of the transaction.

Must be accompanied by a call to transaction_t::commit or transaction_t::abort in order to end a transaction.

Parent db object may have a related error code (via db::error) on failure.

Returns
true on success, false on failure.

The documentation for this struct was generated from the following files: