Ditto 4.5.4
Loading...
Searching...
No Matches
Store.hpp
1#ifndef _DITTO_STORE_
2#define _DITTO_STORE_
3
4#include "Ditto.hpp"
5
6#include "Collection.hpp"
7#include "DiskUsage.hpp"
8#include "PendingCollectionsOperation.hpp"
9#include "QueryResult.hpp"
10#include "StoreObserver.hpp"
11#include "WriteTransaction.hpp"
12#include "WriteTransactionResult.hpp"
13
14#include <functional>
15#include <memory>
16#include <set>
17#include <string>
18#include <vector>
19
20namespace ditto {
21class DittoHandleWrapper;
25class Store {
26 friend class Ditto;
27 friend class StoreObserver;
28
29 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
30 DiskUsage disk_usage;
31 Store(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper);
32 void set_weak_ditto_fields(std::weak_ptr<Ditto::Fields> weak_ditto_fields);
33 std::weak_ptr<Ditto::Fields> weak_ditto_fields;
34
35 bool unregister_observer(std::shared_ptr<StoreObserver>);
36
37public:
38 std::set<std::shared_ptr<StoreObserver>> observers;
39 Store();
40
52 Collection collection(std::string name) const;
53
63 std::vector<std::unique_ptr<WriteTransactionResult>>
64 write(std::function<void(WriteTransaction &)> fn) const;
65
74
81
95 QueryResult execute(std::string query, nlohmann::json query_args = nullptr);
96
110 std::shared_ptr<StoreObserver>
111 register_observer(std::string query, StoreObservationHandler change_handler);
112
129 std::shared_ptr<StoreObserver>
130 register_observer(std::string query, nlohmann::json query_args,
131 StoreObservationHandler change_handler);
132
144 std::shared_ptr<StoreObserver>
145 register_observer(std::string query,
146 StoreObservationHandlerWithNextSignal change_handler);
147
162 std::shared_ptr<StoreObserver>
163 register_observer(std::string query, nlohmann::json query_args,
164 StoreObservationHandlerWithNextSignal change_handler);
165};
166} // namespace ditto
167#endif
A reference to a collection in a Store.
Definition Collection.hpp:26
Provides an interface to be able to monitor local files.
Definition DiskUsage.hpp:65
The entrypoint to the Ditto SDK.
Definition Ditto.hpp:32
These objects are returned when calling collections() on Store objects.
Definition PendingCollectionsOperation.hpp:58
Representes the returned results when executing a DQL query, containing a QueryResultItem for each ma...
Definition QueryResult.hpp:104
Provides access to Collections and a write transaction API.
Definition Store.hpp:25
DiskUsage get_disk_usage() const
Provides access to the Store's disk usage.
Definition Store.cpp:42
std::vector< std::unique_ptr< WriteTransactionResult > > write(std::function< void(WriteTransaction &)> fn) const
Allows you to group multiple operations together that affect multiple documents, potentially across m...
Definition Store.cpp:45
PendingCollectionsOperation collections() const
Returns an object that lets you fetch or observe the collections in the store.
Definition Store.cpp:38
std::shared_ptr< StoreObserver > register_observer(std::string query, StoreObservationHandler change_handler)
Installs and returns a change observer for a query, configuring Ditto to call the provided change han...
Definition Store.cpp:76
std::shared_ptr< StoreObserver > register_observer(std::string query, nlohmann::json query_args, StoreObservationHandlerWithNextSignal change_handler)
Installs and returns a change observer for a query, configuring Ditto to call the provided change han...
QueryResult execute(std::string query, nlohmann::json query_args=nullptr)
Executes a DQL query and returns matching items as a query result.
Definition Store.cpp:57
Collection collection(std::string name) const
Returns a Collection with the provided name.
Definition Store.cpp:34
std::shared_ptr< StoreObserver > register_observer(std::string query, nlohmann::json query_args, StoreObservationHandler change_handler)
Installs and returns a change observer for a query, configuring Ditto to call the provided in change ...
Definition StoreObserver.hpp:45
WriteTransaction exposes functionality that allows you to perform multiple operations on the store wi...
Definition WriteTransaction.hpp:25
basic_json<> json
default JSON class
Definition json.hpp:2933