Provides access to sync related functionality of Ditto.

Access this object via Ditto.sync on any Ditto instance.

Properties

ditto: Ditto

The Ditto instance managed by this sync object.

subscriptions: readonly SyncSubscription[]

All currently active sync subscriptions.

Note: Manage sync subscriptions using registerSubscription() to register a new sync subscription and SyncSubscription.cancel() to remove an existing sync subscription.

Methods

  • Installs and returns a sync subscription for a query, configuring Ditto to receive updates from other peers for documents matching that query. The passed in query must be a SELECT query, otherwise an error is thrown.

    Parameters

    • query: string

      a string containing a valid query expressed in DQL.

    • Optional queryArguments: DQLQueryArguments

      an object containing the arguments for the query. Example: {mileage: 123} for a query with :mileage placeholder.

    Returns SyncSubscription

    An active SyncSubscription for the passed in query and arguments. It will remain active until it is cancelled or the Ditto instance managing the sync subscription has been closed.

    Throws

    DittoError query/invalid: if query argument is not a string or not valid DQL.

    Throws

    DittoError query/arguments-invalid: if queryArguments argument is invalid (e.g. contains unsupported types).

    Throws

    DittoError query/unsupported: if the query is not a SELECT query.

    Throws

    DittoError may throw other errors.