Ditto 4.13.1
 
Loading...
Searching...
No Matches
PendingIDSpecificOperation.hpp
1#ifndef DITTO_PENDING_ID_SPECIFIC_OPERATION_H
2#define DITTO_PENDING_ID_SPECIFIC_OPERATION_H
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
43class DITTO_DEPRECATED_BECAUSE(
44 "Use DQL (Ditto Query Language) instead. For more information see: "
45 "https://ditto.com/link/legacy-to-dql-guide") PendingIDSpecificOperation {
46 DITTO_DISABLE_DEPRECATED_WARNINGS("The legacy query API is deprecated")
47
48 friend class Collection;
49
50 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
51 std::string query;
52
53 PendingIDSpecificOperation(
54 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
55 std::string collection_name, DocumentId id);
56
57 std::shared_ptr<LiveQuery> observe_internal(
58 std::unique_ptr<Subscription> &&subscription,
59 LiveQueryAvailability_t availability,
61
62 std::shared_ptr<LiveQuery> observe_internal(
63 std::unique_ptr<Subscription> &&subscription,
64 LiveQueryAvailability_t availability,
66
67public:
71 // TODO(v5): make collection_name private and provide getter
72 std::string collection_name; // NOLINT
73
77 // TODO(v5): make id private and provide getter
78 DocumentId id; // NOLINT
79
87 std::shared_ptr<Document> exec() const;
88
102 DITTO_DEPRECATED_BECAUSE("Use `update_v2` instead.")
103 std::vector<std::unique_ptr<UpdateResult>>
104 update(std::function<void(MutableDocument &)> fn);
105
117 std::vector<std::unique_ptr<UpdateResult>>
118 update_v2(std::function<void(MutableDocument *)> fn);
119
126 bool remove() const;
127
134 bool evict() const;
135
149 std::shared_ptr<Subscription> subscribe() const;
150
172 std::shared_ptr<LiveQuery>
174
199
200 DITTO_REENABLE_WARNINGS
201};
202} // namespace ditto
203#endif
The type that is returned when calling observe_local. It handles the logic for calling the event hand...
Definition LiveQuery.hpp:149
This is used as part of update operations for documents.
Definition MutableDocument.hpp:34
bool remove() const
Remove the document with the matching ID.
std::shared_ptr< Document > exec() const
Execute the find operation to return the document with the matching ID.
std::shared_ptr< Subscription > subscribe() const
Subscribe to changes from other peers that occur in relation to the relevant document.
DocumentId id
Definition PendingIDSpecificOperation.hpp:78
std::vector< std::unique_ptr< UpdateResult > > update_v2(std::function< void(MutableDocument *)> fn)
Update the document with the matching ID using the provided function.
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.
std::string collection_name
Definition PendingIDSpecificOperation.hpp:72
std::vector< std::unique_ptr< UpdateResult > > update(std::function< void(MutableDocument &)> fn)
Update the document with the matching ID using the provided function.
bool evict() const
Evict the document with the matching ID.
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,...
While Subscription objects remain in scope they ensure that documents in the collection specified,...
Definition Subscription.hpp:26
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
std::function< void(std::shared_ptr< Document >, SingleDocumentLiveQueryEvent)> SingleDocumentLiveQueryEventCallback
A function that will get called when there are updates relating to a live query associated with a sin...
Definition LiveQuery.hpp:32
std::function< void(std::shared_ptr< Document >, SingleDocumentLiveQueryEvent, std::function< void()> &)> SingleDocumentLiveQueryEventWithNextSignalCallback
A function that will get called when there are updates relating to a live query associated with a sin...
Definition LiveQuery.hpp:59
An identifier for a Document.
Definition DocumentId.hpp:23
A thin wrapper around a function that will get called when there are updates relating to a live query...
Definition LiveQuery.hpp:75
Provides information about a successful update operation on a document.
Definition UpdateResult.hpp:35