Ditto  1.0.19
Public Member Functions | Public Attributes | List of all members
ditto::WriteTransactionPendingIDSpecificOperation Class Reference

These objects are returned when ScopedWriteTransaction::find_by_id is called. More...

Public Member Functions

std::shared_ptr< Documentexec ()
 Execute the find operation to return the document with the matching ID, if it exists. More...
 
std::vector< std::unique_ptr< UpdateResult > > update (std::function< void(MutableDocument &)> fn)
 Update the document with the matching ID. More...
 
bool remove ()
 Remove the document with the matching ID. More...
 
bool evict ()
 Evict the document with the matching ID. More...
 

Public Attributes

std::string collection_name
 
DocumentId document_id
 

Detailed Description

These objects are returned when ScopedWriteTransaction::find_by_id is called.

You can use them to perform updates on a document and remove or evict a document.

Member Function Documentation

◆ evict()

bool ditto::WriteTransactionPendingIDSpecificOperation::evict ( )

Evict the document with the matching ID.

Returns
true if the document was found and evicted. false if the document wasn't found and therefore wasn't evicted.

◆ exec()

std::shared_ptr< Document > ditto::WriteTransactionPendingIDSpecificOperation::exec ( )

Execute the find operation to return the document with the matching ID, if it exists.

Returns
The Document with the ID provided in the ScopedWriteTransaction::find_by_id call or nullptr if the document was not found.

◆ remove()

bool ditto::WriteTransactionPendingIDSpecificOperation::remove ( )

Remove the document with the matching ID.

Returns
true if the document was found and removed. false if the document wasn't found and therefore wasn't removed.

◆ update()

std::vector< std::unique_ptr< UpdateResult > > ditto::WriteTransactionPendingIDSpecificOperation::update ( std::function< void(MutableDocument &)>  fn)

Update the document with the matching ID.

Parameters
fna lambda that gets called with the document matching the ID. If found, the document is a MutableDocument, so you can call update-related functions on it. If the document is not found then the value provided to the closure will be nullptr.
Returns
a list of UpdateResult that describes the updates that were performed on the document.

Member Data Documentation

◆ collection_name

std::string ditto::WriteTransactionPendingIDSpecificOperation::collection_name

The name of the collection that the operation will be performed within.

◆ document_id

DocumentId ditto::WriteTransactionPendingIDSpecificOperation::document_id

The ID of the document that the operation will apply to.