Ditto 1.1.7
Public Member Functions | Public Attributes | List of all members
ditto::WriteTransactionPendingCursorOperation Class Reference

These objects are returned when using find-like functionality on ScopedWriteTransactions. You can use them to perform updates on a document and remove or evict a document. More...

#include <WriteTransactionPendingCursorOperation.hpp>

Public Member Functions

WriteTransactionPendingCursorOperationlimit (uint32_t limit)
 Limit the number of documents that get returned when querying a collection for matching documents. More...
 
WriteTransactionPendingCursorOperationoffset (uint32_t offset)
 Offset the resulting set of matching documents. More...
 
WriteTransactionPendingCursorOperationsort (std::string query, SortDirection direction)
 Sort the documents that match the query provided in the preceding find-like function call. More...
 
std::vector< Documentexec () const
 Execute the query generated by the preceding function chaining and return the list of matching documents. More...
 
std::unordered_map< DocumentId, std::vector< std::unique_ptr< UpdateResult > >, DocumentIdHasher > update (std::function< void(std::vector< MutableDocument > &)> fn) const
 Update documents that match the query generated by the preceding function chaining. More...
 
std::vector< DocumentIdremove () const
 Remove all documents that match the query generated by the preceding function chaining. More...
 
std::vector< DocumentIdevict () const
 Evict all documents that match the query generated by the preceding function chaining. More...
 

Public Attributes

std::string collection_name
 
std::string query
 

Detailed Description

These objects are returned when using find-like functionality on ScopedWriteTransactions. You can use them to perform updates on a document and remove or evict a document.

Member Function Documentation

◆ evict()

std::vector< DocumentId > ditto::WriteTransactionPendingCursorOperation::evict ( ) const

Evict all documents that match the query generated by the preceding function chaining.

Returns
a list containing the IDs of the documents that were evicted.

◆ exec()

std::vector< Document > ditto::WriteTransactionPendingCursorOperation::exec ( ) const

Execute the query generated by the preceding function chaining and return the list of matching documents.

Returns
a list of Documents matching the query generated by the preceding function chaining.

◆ limit()

WriteTransactionPendingCursorOperation & ditto::WriteTransactionPendingCursorOperation::limit ( uint32_t  limit)

Limit the number of documents that get returned when querying a collection for matching documents.

Parameters
limitthe maximum number of documents that will be returned.
Returns
a WriteTransactionPendingCursorOperation that you can chain further function calls and then either get the matching documents immediately or get updates about them over time.

◆ offset()

WriteTransactionPendingCursorOperation & ditto::WriteTransactionPendingCursorOperation::offset ( uint32_t  offset)

Offset the resulting set of matching documents.

This is useful if you aren't interested in the first N matching documents for one reason or another. For example, you might already have queried the collection and obtained the first 20 matching documents and so you might want to run the same query as you did previously but ignore the first 20 matching documents, and that is where you would use offset.

Parameters
offsetthe number of matching documents that you want the eventual resulting set of matching documents to be offset by (and thus not include).
Returns
a WriteTransactionPendingCursorOperation that you can chain further function calls and then either get the matching documents immediately or get updates about them over time.

◆ remove()

std::vector< DocumentId > ditto::WriteTransactionPendingCursorOperation::remove ( ) const

Remove all documents that match the query generated by the preceding function chaining.

Returns
a list containing the IDs of the documents that were removed.

◆ sort()

WriteTransactionPendingCursorOperation & ditto::WriteTransactionPendingCursorOperation::sort ( std::string  query,
SortDirection  direction 
)

Sort the documents that match the query provided in the preceding find-like function call.

Parameters
querythe query specifies the logic to be used when sorting the matching documents.
directionspecify whether you want the sorting order to be ascending or descending.
Returns
a WriteTransactionPendingCursorOperation that you can chain further function calls and then either get the matching documents immediately or get updates about them over time.

◆ update()

std::unordered_map< DocumentId, std::vector< std::unique_ptr< UpdateResult > >, DocumentIdHasher > ditto::WriteTransactionPendingCursorOperation::update ( std::function< void(std::vector< MutableDocument > &)>  fn) const

Update documents that match the query generated by the preceding function chaining.

Parameters
fna lambda that gets called with all of the documents matching the query. The documents are MutableDocuments so you can call update-related functions on them.
Returns
a map of document IDs to lists of UpdateResult that describes the updates that were performed for each document.

Member Data Documentation

◆ collection_name

std::string ditto::WriteTransactionPendingCursorOperation::collection_name

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

◆ query

std::string ditto::WriteTransactionPendingCursorOperation::query

The query that will be used when performing the operation.