Ditto 1.1.3
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 "LiveQuery.hpp"
7#include "MutableDocument.hpp"
8#include "Subscription.hpp"
9#include "UpdateResult.hpp"
10
11#include "json.hpp"
12
13#include <functional>
14#include <memory>
15#include <string>
16#include <vector>
17
18namespace ditto {
19
44 friend class Collection;
45
46 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
47 std::string query;
48
50 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
51 std::string collection_name, DocumentId id);
52
53 std::shared_ptr<LiveQuery> observe_internal(
54 Subscription *subscription, LiveQueryAvailability_t availability,
56
57public:
61 std::string collection_name;
62
67
75 std::shared_ptr<Document> exec() const;
76
88 std::vector<std::unique_ptr<UpdateResult>>
89 update(std::function<void(MutableDocument &)> fn);
90
97 bool remove() const;
98
105 bool evict() const;
106
120 Subscription subscribe() const;
121
141 std::shared_ptr<LiveQuery>
142 observe(SingleDocumentLiveQueryEventHandler event_handler) const;
143
165 std::shared_ptr<LiveQuery>
167
188 std::shared_ptr<LiveQuery> observe_with_next_signal(
190
213 std::shared_ptr<LiveQuery> observe_local_with_next_signal(
215};
216} // namespace ditto
217#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:43
std::shared_ptr< LiveQuery > observe_with_next_signal(SingleDocumentLiveQueryWithNextSignalEventHandler event_handler) const
Enables you to listen for changes that occur in relation to the relevant document,...
Definition: PendingIDSpecificOperation.cpp:54
std::shared_ptr< LiveQuery > observe_local_with_next_signal(SingleDocumentLiveQueryWithNextSignalEventHandler event_handler) const
Enables you to listen for changes that occur locally in relation to the relevant document,...
Definition: PendingIDSpecificOperation.cpp:63
std::shared_ptr< LiveQuery > observe(SingleDocumentLiveQueryEventHandler event_handler) const
Enables you to listen for changes that occur in relation to the relevant document.
Definition: PendingIDSpecificOperation.cpp:29
bool remove() const
Remove the document with the matching ID.
Definition: PendingIDSpecificOperation.cpp:143
std::shared_ptr< Document > exec() const
Execute the find operation to return the document with the matching ID.
Definition: PendingIDSpecificOperation.cpp:25
Subscription subscribe() const
Subscribe to changes from other peers that occur in relation to the relevant document.
Definition: PendingIDSpecificOperation.cpp:127
DocumentId id
Definition: PendingIDSpecificOperation.hpp:66
std::shared_ptr< LiveQuery > observe_local(SingleDocumentLiveQueryEventHandler event_handler) const
Enables you to listen for changes that occur locally in relation to the relevant document.
Definition: PendingIDSpecificOperation.cpp:42
std::string collection_name
Definition: PendingIDSpecificOperation.hpp:61
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:132
bool evict() const
Evict the document with the matching ID.
Definition: PendingIDSpecificOperation.cpp:154
While Subscription objects remain in scope they ensure that documents in the collection specified,...
Definition: Subscription.hpp:17
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:29
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition: LiveQuery.hpp:39