Couchbase Lite C++
Couchbase Lite C++ API
Loading...
Searching...
No Matches
cbl::Transaction Class Reference

A helper object for database transactions. More...

#include <cbl++/Database.hh>

Public Member Functions

 Transaction (Database db)
 Begins a batch operation on the database that will end when the Batch instance goes out of scope.
 Transaction (CBLDatabase *db)
 Begins a batch operation on the given C database handle.
void commit ()
 Commits changes and ends the transaction.
void abort ()
 Ends the transaction, rolling back changes.
 ~Transaction ()
 Ends the transaction, rolling back any changes that have not been committed.

Detailed Description

A helper object for database transactions.

A Transaction object should be declared as a local (auto) variable. You must explicitly call commit to commit changes; if you don't, the transaction will abort when it goes out of scope.

Constructor & Destructor Documentation

◆ Transaction() [1/2]

cbl::Transaction::Transaction ( Database db)
inlineexplicit

Begins a batch operation on the database that will end when the Batch instance goes out of scope.

◆ Transaction() [2/2]

cbl::Transaction::Transaction ( CBLDatabase * db)
inlineexplicit

Begins a batch operation on the given C database handle.

Provided for callers that hold a raw CBLDatabase pointer rather than a C++ Database wrapper.

Parameters
dbThe database to begin a transaction on.

◆ ~Transaction()

cbl::Transaction::~Transaction ( )
inline

Ends the transaction, rolling back any changes that have not been committed.

Member Function Documentation

◆ abort()

void cbl::Transaction::abort ( )
inline

Ends the transaction, rolling back changes.

◆ commit()

void cbl::Transaction::commit ( )
inline

Commits changes and ends the transaction.


The documentation for this class was generated from the following file: