Interface UseQueryParams<T>

Parameters for useQuery.

interface UseQueryParams<T> {
    localOnly?: boolean;
    onError?: ((error) => void);
    persistenceDirectory?: string;
    queryArguments?: T;
    subscriptionQuery?: string;
}

Type Parameters

  • T extends DQLQueryArguments = DQLQueryArguments

    The type of query arguments.

Properties

localOnly?: boolean

Whether to run the query locally only.

Setting this to true will skip setting up a SyncSubscription that syncs documents with remote peers. Consequently, the syncSubscription property of the return value will be undefined.

onError?: ((error) => void)

A callback to run when an error occurs.

Type declaration

    • (error): void
    • Parameters

      • error: unknown

      Returns void

Returns

persistenceDirectory?: string

Identifies the Ditto instance to use when multiple instances are registered in the DittoProvider. Defaults to the first registered instance.

See Ditto.absolutePersistenceDirectory.

queryArguments?: T

The arguments to pass to the query.

subscriptionQuery?: string

The query used for the SyncSubscription instead of the observed query. Use this to pass a sync-appropriate query when the observed query carries clauses that Ditto rejects in subscriptions.

Ditto v5 enables DQL_RESTRICT_SUBSCRIPTION by default, so a subscription query containing ORDER BY, LIMIT, or OFFSET throws ("Unsupported feature: Limit or Order by"). When your query needs those clauses for observation, pass an unrestricted subscriptionQuery here so sync still registers. Ignored when UseQueryParams.localOnly is true.