@dxos/echo
    Preparing search index...

    Interface QueryResult<T>

    interface QueryResult<T> {
        atom: Atom<T[]>;
        completeness: Completeness;
        entries: Entry<T>[];
        results: T[];
        sources: readonly SourceState[];
        first(opts?: RunOptions): Promise<T>;
        firstOrUndefined(opts?: RunOptions): Promise<undefined | T>;
        run(opts?: RunOptions): Promise<T[]>;
        runEntries(opts?: RunOptions): Promise<Entry<T>[]>;
        runSync(): T[];
        runSyncEntries(): Entry<T>[];
        subscribe(
            callback?: (query: QueryResult.QueryResult<T>) => void,
            opts?: SubscriptionOptions,
        ): CleanupFn;
    }

    Type Parameters

    • T
    Index

    Properties

    atom: Atom<T[]>

    Self-updating atom. Updates automatically when query results change.

    Memoized per QueryResult instance — repeated accesses on the same instance return the same Atom. Safe only when the QueryResult is itself held stable across re-renders (e.g. behind a useMemo). It must NOT be used in graph-builder connectors/actions or other atom computes, where db.query(...) is called fresh on each re-evaluation: every run constructs a new QueryResult and so a new atom + subscription, leaking the previous ones. Use the memoized atom family there instead.

    O(1) memoized per instance; each emission is a runSync.

    completeness: Completeness

    How much of the answer the current results hold. Reading it never notifies; subscribers are notified only when results change.

    O(sources).

    entries: Entry<T>[]

    Currently available results along with their match metadata.

    Synchronous; O(n) recompute from the working set on first read after a change, cached otherwise.

    results: T[]

    Currently available results.

    Synchronous; O(n) recompute from the working set on first read after a change, cached otherwise.

    sources: readonly SourceState[]

    Per-source progress of the live query.

    O(sources); allocates.

    Methods

    • Returns first result if there is one.

      Parameters

      Returns Promise<undefined | T>

      O(n) in the data examined: runs the full query and takes the first result; .limit(1) bounds the work only where the executor applies the limit before scanning.

    • Returns currently available results synchronously along with their match metadata.

      Returns Entry<T>[]

      Synchronous; working-set results only, recomputed in O(n) after a change and cached otherwise.