Ditto 4.13.1
 
Loading...
Searching...
No Matches
ditto::Transaction Class Reference

Represents a transaction in the Ditto store. More...

Public Member Functions

 ~Transaction ()
 Destructor.
 
 Transaction (const Transaction &)=delete
 
Transactionoperator= (const Transaction &)=delete
 
 Transaction (Transaction &&)=default
 
Transactionoperator= (Transaction &&)=default
 
TransactionInfo get_info () const
 Provides information about the transaction.
 
Storeget_store () const
 The Store this transaction belongs to.
 
QueryResult execute (std::string query, nlohmann::json query_args=nullptr)
 Executes a DQL query and returns matching items as a query result.
 

Detailed Description

Represents a transaction in the Ditto store.

A Transaction is used to group multiple operations into a single atomic unit. This ensures that either all operations within the transaction are applied, or none of them are, maintaining the integrity of the data.

Please consult the documentation of Store::transaction for more information on how to create and use transactions. For a complete guide on transactions, please refer to the Ditto documentation.

See also
`Store::transaction(TransactionOptions, std::function<void(Transaction &)>)`

Member Function Documentation

◆ execute()

QueryResult ditto::Transaction::execute ( std::string query,
nlohmann::json query_args = nullptr )

Executes a DQL query and returns matching items as a query result.

Note
Only returns results from the local store without waiting for any SyncSubscription to have caught up with the latest changes. Only use this method if your program must proceed with immediate results. Use a Observer to receive updates to query results as soon as they have been synced to this peer.
Parameters
querya string containing a valid query expressed in DQL.
query_argsa dictionary of values keyed by the placeholder name without the leading :. Example: {{"mileage", 123}}.
Returns
a QueryResult object containing a QueryResultItem for each match.
Exceptions
`TransactionReadOnlyError`if the transaction is read-only but a mutating query was executed
`DittoError`if the query is not a valid DQL query or if the query fails.