Interface QueryExecuting

Defines the interface for executing DQL queries. Implemented by Store and Transaction.

interface QueryExecuting {
    execute<T, U>(query: string, args?: U): Promise<QueryResult<T>>;
}

Implemented by

Methods

Methods

  • Executes a DQL query and returns matching items as a query result.

    Note: only returns results from the local store without waiting for any sync subscriptions to have caught up with the latest changes. Only use this method if your program must proceed with immediate results. Use a store observer to receive updates to query results as soon as they have been synced to this peer.

    Type Parameters

    • T = any

      The type of items returned by the query. This is a convenience type that is neither inferred from the query parameter nor validated against it.

    • U extends DQLQueryArguments = DQLQueryArguments

      The type of the query arguments

    Parameters

    • query: string

      A string containing a valid query expressed in DQL.

    • Optionalargs: U

      An object of values keyed by the placeholder name without the leading :. Example: { "name": "John" } for a query like SELECT * FROM people WHERE name = :name.

    Returns Promise<QueryResult<T>>

    A promise for a QueryResult containing a QueryResultItem for each match.

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

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

    DittoError transaction-read-only: if a mutating DQL query was attempted using a read-only transaction. (only for the transaction.execute() API).

    DittoError may throw other errors.