1#ifndef DITTO_PENDING_CURSOR_OPERATION_H
2#define DITTO_PENDING_CURSOR_OPERATION_H
5#include "DocumentId.hpp"
7#include "LiveQuery.hpp"
8#include "MutableDocument.hpp"
9#include "SortDirection.hpp"
10#include "Subscription.hpp"
11#include "UpdateResult.hpp"
17#include <unordered_map>
21class DittoHandleWrapper;
47class DITTO_DEPRECATED_BECAUSE(
48 "Use DQL (Ditto Query Language) instead. For more information see: "
49 "https://ditto.com/link/legacy-to-dql-guide") PendingCursorOperation {
50 DITTO_DISABLE_DEPRECATED_WARNINGS(
"The legacy query API is deprecated")
52 friend class Collection;
53 friend class PendingCollectionsOperation;
55 nlohmann::json query_args;
59 PendingCursorOperation(
60 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper,
62 nlohmann::json query_args);
64 PendingCursorOperation() =
default;
65 PendingCursorOperation(PendingCursorOperation &&other)
noexcept;
66 PendingCursorOperation(
const PendingCursorOperation &other);
67 PendingCursorOperation &operator=(PendingCursorOperation other);
70 std::unique_ptr<Impl> impl_;
85 ~PendingCursorOperation();
89 friend void swap(PendingCursorOperation &first,
90 PendingCursorOperation &second)
noexcept {
93 swap(first.collection_name, second.collection_name);
94 swap(first.query, second.query);
95 swap(first.query_args, second.query_args);
96 swap(first._offset, second._offset);
97 swap(first._limit, second._limit);
98 swap(first.impl_, second.impl_);
153 std::vector<Document>
exec()
const;
165 std::unordered_map<DocumentId, std::vector<std::unique_ptr<UpdateResult>>,
167 update(std::function<
void(std::vector<MutableDocument> &)> fn);
183 std::vector<DocumentId>
evict()
const;
218 std::shared_ptr<LiveQuery>
243 DITTO_REENABLE_WARNINGS
std::string query
Definition PendingCursorOperation.hpp:83
std::vector< Document > exec() const
Execute the query generated by the preceding function chaining and return the list of matching docume...
PendingCursorOperation & limit(uint32_t limit)
Limit the number of documents that get returned when querying a collection for matching documents.
std::shared_ptr< LiveQuery > observe_local_with_next_signal(LiveQueryEventWithNextSignalCallback event_callback) const
Enables you to listen for changes that occur on a collection and match the specified query and qualif...
PendingCursorOperation & sort(std::string query, SortDirection direction)
Sort the documents that match the query provided in the preceding find-like function call.
PendingCursorOperation & offset(uint32_t offset)
Offset the resulting set of matching documents.
std::vector< DocumentId > remove() const
Remove all documents that match the query generated by the preceding function chaining.
std::shared_ptr< Subscription > subscribe() const
Subscribe to changes from other peers that occur in the collection.
std::vector< DocumentId > evict() const
Evict all documents that match the query generated by the preceding function chaining.
std::string collection_name
Definition PendingCursorOperation.hpp:77
std::shared_ptr< LiveQuery > observe_local(LiveQueryEventCallback event_callback) const
Enables you to listen for changes that occur on a collection and match the specified query and qualif...
std::unordered_map< DocumentId, std::vector< std::unique_ptr< UpdateResult > >, DocumentIdHasher > update(std::function< void(std::vector< MutableDocument > &)> fn)
Update documents that match the query generated by the preceding function chaining.
Namespace for the Ditto C++ SDK types and functions.
Definition AbstractDocumentPath.hpp:19
SortDirection
Definition SortDirection.hpp:16
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