Ditto 4.9.4
 
Loading...
Searching...
No Matches
PendingIDSpecificOperation.hpp
1#ifndef _DITTO_PENDING_ID_SPECIFIC_OPERATION_
2#define _DITTO_PENDING_ID_SPECIFIC_OPERATION_
3
4#include "Document.hpp"
5#include "DocumentId.hpp"
6#include "Helpers.hpp"
7#include "LiveQuery.hpp"
8#include "MutableDocument.hpp"
9#include "Subscription.hpp"
10#include "UpdateResult.hpp"
11
12#include "json.hpp"
13
14#include <functional>
15#include <memory>
16#include <string>
17#include <vector>
18
19namespace ditto {
20
40class PendingIDSpecificOperation {
41 friend class Collection;
42
43 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
44 std::string query;
45
46 PendingIDSpecificOperation(
47 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
48 std::string collection_name, DocumentId id);
49
50 std::shared_ptr<LiveQuery> observe_internal(
51 std::unique_ptr<Subscription> &&subscription,
52 LiveQueryAvailability_t availability,
54
55 std::shared_ptr<LiveQuery> observe_internal(
56 std::unique_ptr<Subscription> &&subscription,
57 LiveQueryAvailability_t availability,
58 SingleDocumentLiveQueryEventWithNextSignalCallback event_callback) const;
59
60public:
64 std::string collection_name;
65
70
78 std::shared_ptr<Document> exec() const;
79
93 DITTO_DEPRECATED_BECAUSE("Use `update_v2` instead.")
94 std::vector<std::unique_ptr<UpdateResult>>
95 update(std::function<void(MutableDocument &)> fn);
96
108 std::vector<std::unique_ptr<UpdateResult>>
109 update_v2(std::function<void(MutableDocument *)> fn);
110
117 bool remove() const;
118
125 bool evict() const;
126
140 std::shared_ptr<Subscription> subscribe() const;
141
163 std::shared_ptr<LiveQuery>
164 observe_local(SingleDocumentLiveQueryEventCallback event_callback) const;
165
189 SingleDocumentLiveQueryEventWithNextSignalCallback event_callback) const;
190};
191} // namespace ditto
192#endif
The type that is returned when calling observe_local. It handles the logic for calling the event hand...
Definition LiveQuery.hpp:103
This is used as part of update operations for documents.
Definition MutableDocument.hpp:29
bool remove() const
Remove the document with the matching ID.
Definition PendingIDSpecificOperation.cpp:156
std::shared_ptr< Document > exec() const
Execute the find operation to return the document with the matching ID.
Definition PendingIDSpecificOperation.cpp:40
std::shared_ptr< Subscription > subscribe() const
Subscribe to changes from other peers that occur in relation to the relevant document.
Definition PendingIDSpecificOperation.cpp:122
DocumentId id
Definition PendingIDSpecificOperation.hpp:69
std::vector< std::unique_ptr< UpdateResult > > update_v2(std::function< void(MutableDocument *)> fn)
Update the document with the matching ID using the provided function.
Definition PendingIDSpecificOperation.cpp:142
std::shared_ptr< LiveQuery > observe_local(SingleDocumentLiveQueryEventCallback event_callback) const
Enables you to listen for changes that occur locally in relation to the relevant document.
Definition PendingIDSpecificOperation.cpp:44
std::string collection_name
Definition PendingIDSpecificOperation.hpp:64
std::vector< std::unique_ptr< UpdateResult > > update(std::function< void(MutableDocument &)> fn)
Update the document with the matching ID using the provided function.
Definition PendingIDSpecificOperation.cpp:129
bool evict() const
Evict the document with the matching ID.
Definition PendingIDSpecificOperation.cpp:168
std::shared_ptr< LiveQuery > observe_local_with_next_signal(SingleDocumentLiveQueryEventWithNextSignalCallback event_callback) const
Enables you to listen for changes that occur locally in relation to the relevant document,...
Definition PendingIDSpecificOperation.cpp:51
While Subscription objects remain in scope they ensure that documents in the collection specified,...
Definition Subscription.hpp:19
An identifier for a Document.
Definition DocumentId.hpp:21
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:54
Provides information about a successful update operation on a document.
Definition UpdateResult.hpp:30