Ditto 4.11.0
 
Loading...
Searching...
No Matches
ditto::Sync Class Reference

Public Member Functions

std::shared_ptr< SyncSubscriptionregister_subscription (std::string query, nlohmann::json query_args=nullptr)
 Installs and returns a sync subscription for a query, configuring Ditto to receive updates from other peers for documents matching that query. The provided query must be a SELECT query.
 
std::set< std::shared_ptr< SyncSubscription > > get_subscriptions () const
 Returns a snapshot of all active subscriptions.
 

Public Attributes

DITTO_DEPRECATED std::set< std::shared_ptr< SyncSubscription > > subscriptions
 Set of active subscriptions.
 

Member Function Documentation

◆ register_subscription()

std::shared_ptr< SyncSubscription > ditto::Sync::register_subscription ( std::string query,
nlohmann::json query_args = nullptr )

Installs and returns a sync subscription for a query, configuring Ditto to receive updates from other peers for documents matching that query. The provided query must be a SELECT query.

Parameters
querya string containing a valid query expressed in DQL.
argumentsa dictionary of values keyed by the placeholder name without the leading :. Example: {{"mileage", 123}}.
Returns
An active SyncSubscription for the provided query and arguments. You'll have to keep it to be able to cancel the replication subscription, i.e. remove it from the store again. Otherwise it will remain active until Ditto goes out of scope.

Member Data Documentation

◆ subscriptions

DITTO_DEPRECATED std::set<std::shared_ptr<SyncSubscription> > ditto::Sync::subscriptions

Set of active subscriptions.

Deprecated
Use get_subscriptions() instead.

This member should not be accessed by client code. Its contents are managed by the owning Sync instance and will be mutated whenever a subscription is created, canceled, or destroyed.