Ditto 4.13.1
 
Loading...
Searching...
No Matches
PendingCollectionsOperation.hpp
1#ifndef DITTO_PENDING_COLLECTIONS_OPERATION_H
2#define DITTO_PENDING_COLLECTIONS_OPERATION_H
3
4#include "Collection.hpp"
5#include "CollectionsEvent.hpp"
6#include "LiveQuery.hpp"
7#include "PendingCursorOperation.hpp"
8#include "SortDirection.hpp"
9#include "Subscription.hpp"
10
11#include <functional>
12#include <memory>
13#include <string>
14#include <vector>
15
16namespace ditto {
17class DittoHandleWrapper;
18
19DITTO_DISABLE_DEPRECATED_WARNINGS("CollectionsEvent is deprecated")
20
21
25struct DITTO_DEPRECATED_BECAUSE(
26 "Use DQL (Ditto Query Language) instead. For more information see: "
27 "https://ditto.com/link/legacy-to-dql-guide") CollectionsEventHandler {
28 std::function<void(CollectionsEvent)> fn;
29};
30
35struct DITTO_DEPRECATED_BECAUSE(
36 "Use DQL (Ditto Query Language) instead. For more information see: "
37 "https://ditto.com/link/legacy-to-dql-guide")
39 std::function<void(CollectionsEvent, std::function<void()> &)> fn;
40};
41
48using CollectionsEventCallback DITTO_DEPRECATED_BECAUSE(
49 "Use DQL (Ditto Query Language) instead. For more information see: "
50 "https://ditto.com/link/legacy-to-dql-guide") =
51 std::function<void(CollectionsEvent)>;
52
59using CollectionsEventWithNextSignalCallback DITTO_DEPRECATED_BECAUSE(
60 "Use DQL (Ditto Query Language) instead. For more information see: "
61 "https://ditto.com/link/legacy-to-dql-guide") =
62 std::function<void(CollectionsEvent, std::function<void()> &)>;
63
64DITTO_REENABLE_WARNINGS
65
85 * If you want to observe changes in such a way that you can signal when you're
86 * ready for the live query to deliver a new update then you can call
87 * @ref observe_local_with_next_signal.
88 */
89class DITTO_DEPRECATED_BECAUSE(
90 "Use DQL (Ditto Query Language) instead. For more information see: "
91 "https://ditto.com/link/legacy-to-dql-guide") PendingCollectionsOperation {
92 DITTO_DISABLE_DEPRECATED_WARNINGS("The legacy query API is deprecated")
93
94 friend class Store;
95
96 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
97 PendingCursorOperation pending_cursor_operation;
98
99 explicit PendingCollectionsOperation(
100 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper);
101
102public:
103 ~PendingCollectionsOperation();
104
112 PendingCollectionsOperation &limit(uint32_t limit);
113
127 PendingCollectionsOperation &offset(uint32_t offset);
128
139 PendingCollectionsOperation &sort(std::string query, SortDirection direction);
140
141 DITTO_DISABLE_DEPRECATED_WARNINGS("`Collection` is deprecated")
148 std::vector<Collection> exec() const;
149 DITTO_REENABLE_WARNINGS
150
162 std::shared_ptr<Subscription> subscribe() const;
163
176 std::shared_ptr<LiveQuery>
177 observe_local(CollectionsEventCallback event_callback) const;
178
193 CollectionsEventWithNextSignalCallback event_callback) const;
194
195private:
204 buildLiveQueryCallback(CollectionsEventCallback callback,
205 std::shared_ptr<DittoHandleWrapper> dhw);
206
215 buildLiveQueryWithNextSignalCallback(
217 std::shared_ptr<DittoHandleWrapper> dhw);
218
219 DITTO_REENABLE_WARNINGS
220};
221} // namespace ditto
222#endif
A reference to a collection in a Store.
Definition Collection.hpp:31
Provides information about the changes that have occurred in relation to an event delivered when obse...
Definition CollectionsEvent.hpp:26
The type that is returned when calling observe_local. It handles the logic for calling the event hand...
Definition LiveQuery.hpp:149
PendingCollectionsOperation & sort(std::string query, SortDirection direction)
Sort the collections based on a property of the collection.
std::vector< Collection > exec() const
Return the list of collections requested based on the preceding function chaining.
PendingCollectionsOperation & offset(uint32_t offset)
Offset the resulting set of collections.
PendingCollectionsOperation & limit(uint32_t limit)
Limit the number of collections that get returned.
std::shared_ptr< LiveQuery > observe_local(CollectionsEventCallback event_callback) const
Enables you to listen for changes that occur in relation to the collections that are known about loca...
std::shared_ptr< Subscription > subscribe() const
Subscribes the device to updates about collections that other devices know about.
std::shared_ptr< LiveQuery > observe_local_with_next_signal(CollectionsEventWithNextSignalCallback event_callback) const
Enables you to listen for changes that occur in relation to the collections that are known about loca...
These objects are returned when using find-like functionality on Collection objects.
Definition PendingCursorOperation.hpp:49
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
SortDirection
Definition SortDirection.hpp:16
std::function< void(CollectionsEvent, std::function< void()> &)> CollectionsEventWithNextSignalCallback
Type of function called by observe_with_signal methods.
Definition PendingCollectionsOperation.hpp:57
std::function< void(CollectionsEvent)> CollectionsEventCallback
Type of function called by observe methods.
Definition PendingCollectionsOperation.hpp:48
std::function< void(std::vector< Document >, LiveQueryEvent)> LiveQueryEventCallback
A function that will get called when there are updates relating to a live query.
Definition LiveQuery.hpp:88
std::function< void(std::vector< Document >, LiveQueryEvent, std::function< void()> &)> LiveQueryEventWithNextSignalCallback
A function that will get called when there are updates relating to a live query that has an associate...
Definition LiveQuery.hpp:112
Definition PendingCollectionsOperation.hpp:27
Definition PendingCollectionsOperation.hpp:38