Ditto 2.0.6
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
45 friend class Collection;
46
47 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
48 std::string query;
49
51 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
52 std::string collection_name, DocumentId id);
53
54 std::shared_ptr<LiveQuery> observe_internal(
55 Subscription *subscription, LiveQueryAvailability_t availability,
57
58 std::shared_ptr<LiveQuery> observe_internal(
59 Subscription *subscription, LiveQueryAvailability_t availability,
60 SingleDocumentLiveQueryEventWithNextSignalCallback event_callback) const;
61
62public:
66 std::string collection_name;
67
72
80 std::shared_ptr<Document> exec() const;
81
93 std::vector<std::unique_ptr<UpdateResult>>
94 update(std::function<void(MutableDocument &)> fn);
95
102 bool remove() const;
103
110 bool evict() const;
111
125 Subscription subscribe() const;
126
146 std::shared_ptr<LiveQuery>
147 observe(SingleDocumentLiveQueryEventCallback event_callback) const;
148
170 std::shared_ptr<LiveQuery>
171 observe_local(SingleDocumentLiveQueryEventCallback event_callback) const;
172
193 std::shared_ptr<LiveQuery> observe_with_next_signal(
194 SingleDocumentLiveQueryEventWithNextSignalCallback event_callback) const;
195
218 std::shared_ptr<LiveQuery> observe_local_with_next_signal(
219 SingleDocumentLiveQueryEventWithNextSignalCallback event_callback) const;
220};
221} // namespace ditto
222#endif
A reference to a collection in a Store.
Definition: Collection.hpp:26
This is used as part of update operations for documents.
Definition: MutableDocument.hpp:29
These objects are returned when using Collection::find_by_id functionality.
Definition: PendingIDSpecificOperation.hpp:44
std::shared_ptr< LiveQuery > observe(SingleDocumentLiveQueryEventCallback event_callback) const
Enables you to listen for changes that occur in relation to the relevant document.
Definition: PendingIDSpecificOperation.cpp:44
bool remove() const
Remove the document with the matching ID.
Definition: PendingIDSpecificOperation.cpp:155
std::shared_ptr< Document > exec() const
Execute the find operation to return the document with the matching ID.
Definition: PendingIDSpecificOperation.cpp:40
Subscription subscribe() const
Subscribe to changes from other peers that occur in relation to the relevant document.
Definition: PendingIDSpecificOperation.cpp:137
DocumentId id
Definition: PendingIDSpecificOperation.hpp:71
std::shared_ptr< LiveQuery > observe_with_next_signal(SingleDocumentLiveQueryEventWithNextSignalCallback event_callback) const
Enables you to listen for changes that occur in relation to the relevant document,...
Definition: PendingIDSpecificOperation.cpp:59
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:53
std::string collection_name
Definition: PendingIDSpecificOperation.hpp:66
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:144
bool evict() const
Evict the document with the matching ID.
Definition: PendingIDSpecificOperation.cpp:166
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:69
While Subscription objects remain in scope they ensure that documents in the collection specified,...
Definition: Subscription.hpp:18
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:59