Ditto 4.5.3
|
Provides access to Collection
s and a write transaction API.
More...
#include <Store.hpp>
Public Member Functions | |
Collection | collection (std::string name) const |
Returns a Collection with the provided name. | |
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 multiple collections. | |
PendingCollectionsOperation | collections () const |
Returns an object that lets you fetch or observe the collections in the store. | |
DiskUsage | get_disk_usage () const |
Provides access to the Store's disk usage. | |
QueryResult | execute (std::string query, nlohmann::json query_args=nullptr) |
Executes a DQL query and returns matching items as a query result. | |
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 handler whenever documents in the local store change such that the result of the matching query changes. The provided query must be a SELECT query. | |
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 handler whenever documents in the local store change such that the result of the matching query changes. The provided query must be a SELECT query. | |
std::shared_ptr< StoreObserver > | register_observer (std::string query, StoreObservationHandlerWithNextSignal change_handler) |
Installs and returns a change observer for a query, configuring Ditto to call the provided change handler whenever documents in the local store change such that the result of the matching query changes. The provided query must be a SELECT query. | |
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 handler whenever documents in the local store change such that the result of the matching query changes. The provided query must be a SELECT query. | |
Public Attributes | |
std::set< std::shared_ptr< StoreObserver > > | observers |
Provides access to Collection
s and a write transaction API.
Collection ditto::Store::collection | ( | std::string | name | ) | const |
Returns a Collection
with the provided name.
[in] | name | the name of the collection. A name is valid if:
|
Collection
. if | name is not a valid Collection name. |
PendingCollectionsOperation ditto::Store::collections | ( | ) | const |
Returns an object that lets you fetch or observe the collections in the store.
PendingCollectionsOperation
object that you can use to fetch or observe the collections in the store QueryResult ditto::Store::execute | ( | std::string | query, |
nlohmann::json | query_args = nullptr ) |
Executes a DQL query and returns matching items as a query result.
query | a string containing a valid query expressed in DQL. |
query_args | a dictionnary of values keyed by the placeholder name without the leading : . |
Limitations:
SELECT * FROM <collection_name>
with optional WHERE <expression>
.DiskUsage ditto::Store::get_disk_usage | ( | ) | const |
std::shared_ptr< StoreObserver > ditto::Store::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 handler whenever documents in the local store change such that the result of the matching query changes. The provided query must be a SELECT
query.
query | a string containing a valid query expressed in DQL. |
arguments | a dictionary of values keyed by the placeholder name without the leading : . Example: {{"mileage", 123}} . |
StoreObserver
for the provided query and arguments. You'll have to keep it in scope to keep receiving changes.DittoError
if the query is not a valid DQL query. std::shared_ptr< StoreObserver > ditto::Store::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 handler whenever documents in the local store change such that the result of the matching query changes. The provided query must be a SELECT
query.
query | a string containing a valid query expressed in DQL. |
query_args | a dictionary of values keyed by the placeholder name without the leading : . Example: {{"mileage", 123}} . |
StoreObserver
for the provided query and arguments. You'll have to keep it in scope to receive changes. std::shared_ptr< StoreObserver > ditto::Store::register_observer | ( | std::string | query, |
StoreObservationHandler | change_handler ) |
Installs and returns a change observer for a query, configuring Ditto to call the provided change handler whenever documents in the local store change such that the result of the matching query changes. The provided query must be a SELECT
query.
query | a string containing a valid query expressed in DQL. |
StoreObserver
for the provided query. You'll have to keep it in scope to receive changes.DittoError
if the query is not a valid DQL query. std::shared_ptr< StoreObserver > ditto::Store::register_observer | ( | std::string | query, |
StoreObservationHandlerWithNextSignal | change_handler ) |
Installs and returns a change observer for a query, configuring Ditto to call the provided change handler whenever documents in the local store change such that the result of the matching query changes. The provided query must be a SELECT
query.
query | a string containing a valid query expressed in DQL. |
StoreObserver
for the provided query. You'll have to keep it in scope to keep receiving changes. std::vector< std::unique_ptr< WriteTransactionResult > > ditto::Store::write | ( | std::function< void(WriteTransaction &)> | fn | ) | const |
Allows you to group multiple operations together that affect multiple documents, potentially across multiple collections.
fn | a lambda that provides access to a write transaction object that can be used to perform operations on the store. |
WriteTransactionResult
s. There is a result for each operation performed as part of the write transaction.