Prometheus Entity Management API
    Preparing search index...

    adapters/pglite-persistence.ts

    PGlite-backed implementation of GraphPersistenceAdapter.

    Stores the local-first runtime's graph snapshot inside a PGlite table (_graph_snapshot by default) instead of localStorage/IndexedDB.

    Why this exists:

    • The app already has a PGlite handle for ElectricSQL sync.
    • Putting the graph snapshot alongside synced data means one storage surface to back up, clear, and reason about.
    • Works in Tauri WebView + Node (PGlite is a WASM Postgres) without pulling in browser-only storage.

    Contract:

    • get(key) -> returns the stored string or null
    • set(key, v) -> upserts (insert-or-replace), stamping updated_at
    • remove(key) -> deletes the row (no-op if absent)

    The function lazily ensures the storage table exists on first call. That CREATE TABLE IF NOT EXISTS is idempotent so it's safe to retry.

    Self-hosted Supabase only. HotSeatersMVP is the bible. This module does not import @electric-sql/pglite — consumers pass a PGlite-shaped handle.

    interface PGlitePersistenceClient {
        exec(sql: string): Promise<unknown>;
        query<T = Record<string, unknown>>(
            sql: string,
            params?: unknown[],
        ): Promise<{ rows: T[] }>;
    }
    Index
    • Parameters

      • sql: string

      Returns Promise<unknown>

    • Type Parameters

      • T = Record<string, unknown>

      Parameters

      • sql: string
      • Optionalparams: unknown[]

      Returns Promise<{ rows: T[] }>