2#ifndef _MDBX_CONTAINERS_BASE_DB_HPP_INCLUDED
3#define _MDBX_CONTAINERS_BASE_DB_HPP_INCLUDED
22 explicit BaseTable(std::shared_ptr<Connection> connection,
24 MDBX_db_flags_t flags)
28 mdbx_dbi_open(txn.handle(), name.c_str(), flags, &
m_dbi),
29 "Failed to open table"
74 template<
typename Func>
void begin(TransactionMode mode=TransactionMode::WRITABLE)
Begins a manual transaction (must be committed or rolled back later).
MDBX_txn * thread_txn() const
Returns the transaction bound to the current thread, if any.
MDBX_dbi m_dbi
DBI handle for the opened table.
MDBX_dbi handle() const
Gets the raw DBI handle.
void connect()
Connects to the MDBX environment if not already connected.
void execute_in_transaction(Func operation, TransactionMode mode=TransactionMode::WRITABLE)
Executes an operation inside an automatic transaction.
void commit()
Commits the current manual transaction.
void rollback()
Rolls back the current manual transaction.
void disconnect()
Disconnects the MDBX environment.
BaseTable(std::shared_ptr< Connection > connection, std::string name, MDBX_db_flags_t flags)
Construct the database table accessor.
bool is_connected() const
Checks if the connection is currently active.
virtual ~BaseTable()=default
std::shared_ptr< Connection > m_connection
Shared connection to MDBX environment.
void check_mdbx(int rc, const std::string &context)
Throws an MdbxException if MDBX return code indicates an error.
TransactionMode
Specifies the access mode of a transaction.
@ WRITABLE
Writable transaction (allows inserts, updates, deletes).