Interface StorageResolutionOptions

interface StorageResolutionOptions {
    filePath?: string;
    priority?: AdapterKind[];
    capacitor?: CapacitorAdapterOptions;
    postgres?: PostgresAdapterOptions;
    indexedDb?: IndexedDbAdapterOptions;
    openOptions?: StorageOpenOptions;
    quiet?: boolean;
    logger?: StorageLogger;
    strict?: boolean;
    segment?: string;
}

Properties

filePath?: string

Absolute path for sqlite file (used by better-sqlite3/sql.js when persistence is desired).

priority?: AdapterKind[]

Explicit adapter priority override. The resolver builds postgres, better-sqlite3, capacitor, indexeddb and sqljs; memory builds sql.js, as sqljs does. Any other kind (electron-main, electron-renderer, supabase, or an unknown name) fails as a candidate with an error that names it, and the resolver goes on to the next one.

Options passed to the Capacitor adapter.

Options passed to the Postgres adapter, all of them: a connection string, or host, port, database, user and password, and the pool, SSL and timeout settings. Without a connection string or a host, database or user here, the connection string comes from DATABASE_URL.

Options passed to the IndexedDB adapter (browser persistence), all of them.

openOptions?: StorageOpenOptions

Options forwarded to adapter.open.

quiet?: boolean

Suppress fallback chain logs (adapter not-found warnings). Default: false.

logger?: StorageLogger

The logger for this call's resolver lines (pino's fits). Default: the one setStorageLogger() set, else the console.

strict?: boolean

Strict resolution, for servers: only the database the options name opens. Default: false.

  • The postgres candidate is the last one tried. When it fails to open, resolution throws a StorageResolutionError instead of trying a local SQLite database, whatever priority lists after it.
  • A Postgres server named by postgres or DATABASE_URL, with no priority, makes ['postgres'] the whole list.
  • An explicit filePath outranks DATABASE_URL: with a filePath and no postgres options that name a server, DATABASE_URL is not read.
  • postgres options that name no server, with no DATABASE_URL to fill in and no filePath, fail instead of opening the local default.

Without strict, a postgres candidate that fails falls through to the next candidate, and DATABASE_URL puts Postgres first even when a filePath is given.

segment?: string

Keeps the resolved adapter's tables apart from other users of the same database: on PostgreSQL a schema of the segment's name, on better-sqlite3 and sql.js a file with the segment in its name (app.sqlite3 becomes app-agentos.sqlite3), on IndexedDB and Capacitor a database name with the segment appended (app-db-agentos). Lower-case letters, digits and underscores; not public, information_schema or a name beginning with pg_. A name that cannot be a segment is refused before any adapter is tried, here or in postgres, indexedDb or capacitor, and so is a segment with postgres.pool, which the Postgres adapter cannot start in the segment. Takes the place of a segment in postgres, indexedDb or capacitor.

Without it, a local candidate whose options name no segment of their own (better-sqlite3 and sql.js have none), tried after a candidate whose options named one and failed, opens in that candidate's segment: a resolution that asked for a segment never falls through to the database every user of the file or the browser shares. A postgres candidate opens in the segment of its own options alone.