Skip to content

createPostgresStorage

function createPostgresStorage(options?): PostgresAuditStorage;

Defined in: src/storage/postgres.ts:99

Create a Postgres-backed PostgresAuditStorage. The tables are created lazily on first use; connection (when using connectionString/url) is also lazy — the pg Pool is imported and constructed on the first operation and reused thereafter.

Parameter Type
options? PostgresStorageOptions

PostgresAuditStorage

import { createPostgresStorage } from "@xtandard/audit/storage/postgres";
// Via connection string (lazy `pg` Pool):
const storage = createPostgresStorage({
connectionString: process.env.DATABASE_URL,
});
// Or with a pre-built pg Pool / PGlite client:
// import { PGlite } from "@electric-sql/pglite";
// const storage = createPostgresStorage({ client: new PGlite() });