PostgreSQL Backend
Shared PostgreSQL storage with connection pooling, JSONB metadata, and optional pgvector.
What is it?
A StorageProvider implementation backed by PostgreSQL via the optional pg peer. Same public API as SQLite.
Why does it exist?
Teams that already run Postgres, or need multi-process / multi-host readers and writers against one database.
How does it work?
npm install pgimport { postgres } from "wolbarg";
storage: postgres(process.env.DATABASE_URL!)
// or
storage: postgres({
connectionString: process.env.DATABASE_URL!,
schema: "wolbarg", // optional namespaced deployment
maxPoolSize: 20, // default since 0.6.0; raise only if the host allows
})Features:
- Connection pooling (default
maxPoolSize20) - Remote hosts without
sslmode/sslin the URL getsslmode=require(loopback unchanged) - Optional
schemafor tables, indexes, and NOTIFY channels - JSONB metadata + GIN index
- pgvector when the extension is available (BYTEA + cosine fallback otherwise)
Install the optional pg peer before using postgres(). Operator details: Production.
API parity
Both backends implement the same StorageProvider contract: insert, batch insert, update, delete, vector search, metadata listing, history, transactions, and migrations. Switch storage by changing one constructor option.
When should it be used?
Use PostgreSQL when multiple application instances share memory, or when you need central backups and ops. Use SQLite when the agent is single-node and file-based storage is enough.