Skip to content

@xtandard/audit/storage/postgres

Postgres storage: createPostgresStorage() keeps a jsonb key/value table plus the native event-log tables (indexed queries, atomic appends), all created on first use. Works with pg or PGlite.

import { … } from "@xtandard/audit/storage/postgres";
Name Summary
createPostgresStorage 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.
Name Summary
PostgresAuditStorage A storage backed by Postgres with the native EventLogStorage capability and compareAndSwap, plus a close() method that ends the underlying pool — but only the one this adapter created. A client you passed in is left for you to manage.
Name Summary
PostgresStorageOptions Options for createPostgresStorage: a client (pg Pool/Client, PGlite) or a connectionString/url, and the KV table (default "xtandard_audit"); the event log uses {table}_events and {table}_event_targets. Must be a safe SQL identifier.