Metreeca Wire
    Preparing search index...

    SPARQL repository.

    The interface connector packages implement to expose a concrete SPARQL backend: executing SPARQL queries and updates against the backing RDF store, with transactional execute and lifecycle close.

    Important

    execute provides best-effort transaction isolation: snapshot isolation where the backend supports it, degrading to the maximum level the storage achieves, down to none.

    Important

    Each implementation must declare its supported isolation level in its factory documentation.

    interface Repository {
        ask(query: string): Promise<boolean>;
        select(query: string): Promise<readonly Tuple[]>;
        construct(query: string): Promise<readonly Triple[]>;
        update(update: string): Promise<void>;
        execute<V>(task: (repository: Repository) => V | Promise<V>): Promise<V>;
        close(): Promise<void>;
    }
    Index

    Methods

    • Execute an ASK query.

      Parameters

      • query: string

        The SPARQL ASK query

      Returns Promise<boolean>

      A promise resolving to true if the query pattern matches; false otherwise

    • Execute a task within a repository transaction.

      The task receives a per-call Repository bound to a transaction; updates issued through it are applied within the transaction in order. If the task completes successfully, the transaction commits. If the task throws or rejects, the transaction rolls back and the error is propagated to the caller as a promise rejection. Concurrent top-level execute calls run in independent transactions and never share state.

      Warning

      execute is not re-entrant. Transaction boundaries are flat and compositions must share a single outer call site.

      Important

      Every implementation must provide execute, but its guarantees are backend-dependent. A backend with native transactions brackets the task for atomic commit and rollback. A backend without one supplies a degenerate implementation: the task runs directly against this same Repository, with no atomicity and no rollback. Either way, each implementation declares the isolation level it provides in its own factory documentation.

      Type Parameters

      • V

        Return type of the task

      Parameters

      • task: (repository: Repository) => V | Promise<V>

        Async or sync function performing SPARQL operations on the per-call Repository

      Returns Promise<V>

      A promise resolving to the value returned by task; rejects with a Problem if a transaction, network, storage, or other processing error occurs

    • Release resources held by this repository.

      Frees underlying resources such as database connections or file handles. Calling close on an already-closed repository has no effect.

      Important

      Every implementation must provide close, but it is degenerate where there is nothing to release: a backend that holds no resources implements it as a resolved no-op.

      Returns Promise<void>

      A promise resolving when all resources have been released; rejects with a Problem if a clean-up error occurs