Ditto 3.0.11
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
ditto::ScopedWriteTransaction Class Reference

ScopedWriteTransaction exposes functionality that allows you to perform multiple operations on the store within a single write transaction. More...

#include <ScopedWriteTransaction.hpp>

Public Member Functions

DocumentId upsert (nlohmann::json content, WriteStrategy write_strategy=WriteStrategy::merge) const
 Inserts a new document into the collection and returns its ID. If the document already exists, the behavior is determined by the given write_strategy.
 
WriteTransactionPendingIDSpecificOperation find_by_id (DocumentId id) const
 Generates a WriteTransactionPendingIDSpecificOperation with the provided document ID that can be used to update, remove, or evict the document.
 
WriteTransactionPendingCursorOperation find_all () const
 Generates a WriteTransactionPendingCursorOperation that can be used to update, remove or evict documents.
 
WriteTransactionPendingCursorOperation find (std::string query) const
 Generates a WriteTransactionPendingCursorOperation with the provided query that can be used to update, remove, or evict documents.
 
WriteTransactionPendingCursorOperation find (std::string query, nlohmann::json query_args) const
 Generates a WriteTransactionPendingCursorOperation with the provided query that can be used to update, remove, or evict documents.
 

Public Attributes

std::string collection_name
 

Detailed Description

ScopedWriteTransaction exposes functionality that allows you to perform multiple operations on the store within a single write transaction.

Member Function Documentation

◆ find() [1/2]

WriteTransactionPendingCursorOperation ditto::ScopedWriteTransaction::find ( std::string  query) const

Generates a WriteTransactionPendingCursorOperation with the provided query that can be used to update, remove, or evict documents.

Parameters
querythe query to run against the collection.
Returns
a WriteTransactionPendingCursorOperation that you can use to chain further query-related function calls.

◆ find() [2/2]

WriteTransactionPendingCursorOperation ditto::ScopedWriteTransaction::find ( std::string  query,
nlohmann::json  query_args 
) const

Generates a WriteTransactionPendingCursorOperation with the provided query that can be used to update, remove, or evict documents.

This is the recommended function to use when performing queries on a collection if you have any dynamic data included in the query string. It allows you to provide a query string with placeholders, in the form of $args.my_arg_name, along with an accompanying dictionary of arguments, in the form of { "my_arg_name": "some value" }, and the placeholders will be appropriately replaced by the matching provided arguments from the dictionary. This includes handling things like wrapping strings in quotation marks and arrays in square brackets, for example.

Parameters
querythe query to run against the collection.
query_argsthe arguments to use to replace placeholders in the provided query.
Returns
a WriteTransactionPendingCursorOperation that you can use to chain further query-related function calls.

◆ find_all()

WriteTransactionPendingCursorOperation ditto::ScopedWriteTransaction::find_all ( ) const

Generates a WriteTransactionPendingCursorOperation that can be used to update, remove or evict documents.

Returns
a WriteTransactionPendingCursorOperation that you can use to chain further query-related function calls.

◆ find_by_id()

WriteTransactionPendingIDSpecificOperation ditto::ScopedWriteTransaction::find_by_id ( DocumentId  id) const

Generates a WriteTransactionPendingIDSpecificOperation with the provided document ID that can be used to update, remove, or evict the document.

Parameters
idthe ID of the document.
Returns
a WriteTransactionPendingIDSpecificOperation that you can chain function calls to either get the document immediately or get updates about it over time.

◆ upsert()

DocumentId ditto::ScopedWriteTransaction::upsert ( nlohmann::json  content,
WriteStrategy  write_strategy = WriteStrategy::merge 
) const

Inserts a new document into the collection and returns its ID. If the document already exists, the behavior is determined by the given write_strategy.

Parameters
[in]contentthe value to insert into the collection.
write_strategyspecifies the desired strategy for inserting a document. The default value is WriteStrategy::merge.
Returns
the ID of the inserted document.

Member Data Documentation

◆ collection_name

std::string ditto::ScopedWriteTransaction::collection_name

The name of the collection that the scoped write transaction is scoped to.