Represents a transaction in the Ditto store.

A Transaction groups multiple operations into a single atomic unit, ensuring that all operations within the transaction are either fully applied or not applied at all, thereby maintaining data integrity.

For more information on creating and using transactions, refer to the ditto.store.transaction() method. For a comprehensive guide on transactions, please visit the Ditto documentation.

Implements

Constructors

Properties

Accessors

Methods

Constructors

Properties

store: Store

The store this transaction belongs to.

Accessors

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.

    • OptionalqueryArguments: U

    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.