Ditto 4.13.1
 
Loading...
Searching...
No Matches
WriteTransactionPendingCursorOperation.hpp
1#ifndef DITTO_WRITE_TRANSACTION_PENDING_CURSOR_OPERATION_H
2#define DITTO_WRITE_TRANSACTION_PENDING_CURSOR_OPERATION_H
3
4#include "Document.hpp"
5#include "DocumentId.hpp"
6#include "MutableDocument.hpp"
7#include "SortDirection.hpp"
8#include "UpdateResult.hpp"
9#include "WriteTransaction.hpp"
10
11#include <functional>
12#include <memory>
13#include <string>
14#include <unordered_map>
15#include <vector>
16
17namespace ditto {
18class DittoHandleWrapper;
19
28class DITTO_DEPRECATED_BECAUSE(
29 "Use DQL (Ditto Query Language) instead. For more information see: "
30 "https://ditto.com/link/legacy-to-dql-guide")
31 WriteTransactionPendingCursorOperation {
32 DITTO_DISABLE_DEPRECATED_WARNINGS("The legacy query API is deprecated")
33
34 friend class ScopedWriteTransaction;
35
36 nlohmann::json query_args;
37 // NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
38 WriteTransaction &base_transaction;
39 uint32_t _offset = 0;
40 int32_t _limit = -1;
41
42 WriteTransactionPendingCursorOperation(
43 std::string collection_name, std::string query, nlohmann::json query_args,
44 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
45 WriteTransaction &base_transaction);
46
47 WriteTransactionPendingCursorOperation(
48 WriteTransactionPendingCursorOperation &&other) noexcept;
49 WriteTransactionPendingCursorOperation &
50 operator=(WriteTransactionPendingCursorOperation &&other) noexcept;
51
52 class Impl;
53 std::unique_ptr<Impl> impl_;
54
55public:
56 ~WriteTransactionPendingCursorOperation();
57
61 // TODO(v5): make collection_name private and provide a getter
62 std::string collection_name; // NOLINT
63
67 // TODO(v5): make query private and provide a getter
68 std::string query; // NOLINT
69
79 WriteTransactionPendingCursorOperation &limit(uint32_t limit);
80
96 WriteTransactionPendingCursorOperation &offset(uint32_t offset);
97
112 WriteTransactionPendingCursorOperation &sort(std::string query,
113 SortDirection direction);
114
122 std::vector<Document> exec() const;
123
134 std::unordered_map<DocumentId, std::vector<std::unique_ptr<UpdateResult>>,
135 DocumentIdHasher>
136 update(std::function<void(std::vector<MutableDocument> &)> fn) const;
137
144 std::vector<DocumentId> remove() const;
145
152 std::vector<DocumentId> evict() const;
153
154 DITTO_REENABLE_WARNINGS
155};
156} // namespace ditto
157#endif
WriteTransaction exposes functionality that allows you to perform multiple operations on the store wi...
Definition WriteTransaction.hpp:30
WriteTransactionPendingCursorOperation & limit(uint32_t limit)
Limit the number of documents that get returned when querying a collection for matching documents.
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.
std::vector< DocumentId > remove() const
Remove all documents that match the query generated by the preceding function chaining.
WriteTransactionPendingCursorOperation & sort(std::string query, SortDirection direction)
Sort the documents that match the query provided in the preceding find-like function call.
std::string query
Definition WriteTransactionPendingCursorOperation.hpp:68
std::vector< DocumentId > evict() const
Evict all documents that match the query generated by the preceding function chaining.
std::string collection_name
Definition WriteTransactionPendingCursorOperation.hpp:62
std::vector< Document > exec() const
Execute the query generated by the preceding function chaining and return the list of matching docume...
WriteTransactionPendingCursorOperation & offset(uint32_t offset)
Offset the resulting set of matching documents.
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
SortDirection
Definition SortDirection.hpp:16