{"_id":"@airnauts/comments-adapter-postgres","_rev":"4-f1f4d095b34a7db845da8829615b2784","name":"@airnauts/comments-adapter-postgres","dist-tags":{"latest":"0.7.0"},"versions":{"0.5.1":{"name":"@airnauts/comments-adapter-postgres","version":"0.5.1","keywords":["comments","commenting","annotations","feedback","airnauts","postgres","postgresql","adapter"],"author":{"name":"Airnauts"},"license":"MIT","_id":"@airnauts/comments-adapter-postgres@0.5.1","maintainers":[{"name":"jkrzemie","email":"hello@airnauts.com"},{"name":"mateuszpaulski","email":"mateusz@airnauts.com"}],"homepage":"https://github.com/Airnauts/commenting-tool#readme","bugs":{"url":"https://github.com/Airnauts/commenting-tool/issues"},"dist":{"shasum":"9e37b0ffd0b319e787e8afa4b845300719893687","tarball":"https://registry.npmjs.org/@airnauts/comments-adapter-postgres/-/comments-adapter-postgres-0.5.1.tgz","fileCount":11,"integrity":"sha512-1Y6TthKotgJC90Rdk9RAlGVJkkoWqSeeAuAvItXa6029W0UxjfJ5FS8V51/y5K2wZIcuvQgugVIReFn5jt3Y+A==","signatures":[{"sig":"MEQCIECxFnltJak7Rr7bXs5Ol/cvXU8+5dCnNGlMJkVaEsFvAiBQm2FXVmfLzunkiT+SXsVSd9c0rBTLJDEY6nDmOpdtdQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37553},"type":"module","_from":"file:airnauts-comments-adapter-postgres-0.5.1.tgz","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsup && tsc --build --force","typecheck":"tsc --build"},"_npmUser":{"name":"mateuszpaulski","email":"mateusz@airnauts.com"},"_resolved":"/tmp/347499b581fcbcfabd145e2be3d87ae8/airnauts-comments-adapter-postgres-0.5.1.tgz","_integrity":"sha512-1Y6TthKotgJC90Rdk9RAlGVJkkoWqSeeAuAvItXa6029W0UxjfJ5FS8V51/y5K2wZIcuvQgugVIReFn5jt3Y+A==","repository":{"url":"git+https://github.com/Airnauts/commenting-tool.git","type":"git","directory":"packages/adapter-postgres"},"_npmVersion":"10.9.8","description":"PostgreSQL repository adapter for the Airnauts commenting tool server.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@airnauts/comments-core":"^0.5.1","@airnauts/comments-server":"^0.5.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.11.0","@types/pg":"^8.11.0","@electric-sql/pglite":"^0.5.1","@airnauts/comments-test-support":"0.0.0"},"peerDependencies":{"pg":"^8.11.0"},"peerDependenciesMeta":{"pg":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/comments-adapter-postgres_0.5.1_1781524861439_0.6648261724100497","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Renamed to @airnauts/airside-adapter-postgres — install that instead. No longer maintained."},"0.6.0":{"name":"@airnauts/comments-adapter-postgres","version":"0.6.0","keywords":["comments","commenting","annotations","feedback","airnauts","postgres","postgresql","adapter"],"author":{"name":"Airnauts"},"license":"MIT","_id":"@airnauts/comments-adapter-postgres@0.6.0","maintainers":[{"name":"jkrzemie","email":"hello@airnauts.com"},{"name":"mateuszpaulski","email":"mateusz@airnauts.com"}],"homepage":"https://github.com/Airnauts/commenting-tool#readme","bugs":{"url":"https://github.com/Airnauts/commenting-tool/issues"},"dist":{"shasum":"8c08f7548b6c775c34e054137a1309afc2bd42de","tarball":"https://registry.npmjs.org/@airnauts/comments-adapter-postgres/-/comments-adapter-postgres-0.6.0.tgz","fileCount":11,"integrity":"sha512-nJ2o9oBZMHQFcsba+iBVcbtlqNnaJS3ksXjHmnxhUd5dQxeeC8OITnoj7ukND4cAPX3zDojCSvIjWRfQ0NTh9A==","signatures":[{"sig":"MEQCIEf9BzRFZ5c7Kchl6yNYKvFe4FUO0VDEMPsWs6QuEpBuAiB3bRcYmBOAxycYUAhw1J+dGmyTQ7T3pjiU0WebDcjfbA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37585},"type":"module","_from":"file:airnauts-comments-adapter-postgres-0.6.0.tgz","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsup && tsc --build --force","typecheck":"tsc --build"},"_npmUser":{"name":"mateuszpaulski","email":"mateusz@airnauts.com"},"_resolved":"/tmp/268673a4db10556e1dc50f3999bc6bbb/airnauts-comments-adapter-postgres-0.6.0.tgz","_integrity":"sha512-nJ2o9oBZMHQFcsba+iBVcbtlqNnaJS3ksXjHmnxhUd5dQxeeC8OITnoj7ukND4cAPX3zDojCSvIjWRfQ0NTh9A==","repository":{"url":"git+https://github.com/Airnauts/commenting-tool.git","type":"git","directory":"packages/adapter-postgres"},"_npmVersion":"10.9.8","description":"PostgreSQL repository adapter for the Airnauts commenting tool server.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@airnauts/comments-core":"^0.6.0","@airnauts/comments-server":"^0.6.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.11.0","@types/pg":"^8.11.0","@electric-sql/pglite":"^0.5.1","@airnauts/comments-test-support":"0.0.0"},"peerDependencies":{"pg":"^8.11.0"},"peerDependenciesMeta":{"pg":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/comments-adapter-postgres_0.6.0_1781537514071_0.6329778058636073","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Renamed to @airnauts/airside-adapter-postgres — install that instead. No longer maintained."},"0.7.0":{"name":"@airnauts/comments-adapter-postgres","version":"0.7.0","keywords":["comments","commenting","annotations","feedback","airnauts","postgres","postgresql","adapter"],"author":{"name":"Airnauts"},"license":"MIT","_id":"@airnauts/comments-adapter-postgres@0.7.0","maintainers":[{"name":"jkrzemie","email":"hello@airnauts.com"},{"name":"mateuszpaulski","email":"mateusz@airnauts.com"}],"homepage":"https://github.com/Airnauts/commenting-tool#readme","bugs":{"url":"https://github.com/Airnauts/commenting-tool/issues"},"dist":{"shasum":"5ab9379bc0ee2af21652ce605c9125e8b269c2a0","tarball":"https://registry.npmjs.org/@airnauts/comments-adapter-postgres/-/comments-adapter-postgres-0.7.0.tgz","fileCount":11,"integrity":"sha512-wop2tpdwRwRfDlbDafbe/3iYWLvIY8lT2vDiWoY386sfdpwwOoEKMemVNNmBq+hNOD6/XPrGZzyNZOLpSjDCgw==","signatures":[{"sig":"MEUCIQCJ1KpfzFdZDvh42sBWxItvfxKp5Tbm0ktIbF2HOSyPjgIgDUwn6NGeY6jvJsjRxBsHPrwv2cOCh8KShAUNuij7ngU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37585},"type":"module","_from":"file:airnauts-comments-adapter-postgres-0.7.0.tgz","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"test":"vitest run","build":"tsup && tsc --build --force","typecheck":"tsc --build"},"_npmUser":{"name":"mateuszpaulski","email":"mateusz@airnauts.com"},"_resolved":"/tmp/b97c1497a606e30182e073a35473bdbf/airnauts-comments-adapter-postgres-0.7.0.tgz","_integrity":"sha512-wop2tpdwRwRfDlbDafbe/3iYWLvIY8lT2vDiWoY386sfdpwwOoEKMemVNNmBq+hNOD6/XPrGZzyNZOLpSjDCgw==","repository":{"url":"git+https://github.com/Airnauts/commenting-tool.git","type":"git","directory":"packages/adapter-postgres"},"_npmVersion":"10.9.8","description":"PostgreSQL repository adapter for the Airnauts commenting tool server.","directories":{},"_nodeVersion":"22.22.3","dependencies":{"@airnauts/comments-core":"^0.7.0","@airnauts/comments-server":"^0.7.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"pg":"^8.11.0","@types/pg":"^8.11.0","@electric-sql/pglite":"^0.5.1","@airnauts/comments-test-support":"0.0.0"},"peerDependencies":{"pg":"^8.11.0"},"peerDependenciesMeta":{"pg":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/comments-adapter-postgres_0.7.0_1781540305118_0.8640249625796523","host":"s3://npm-registry-packages-npm-production"},"deprecated":"Renamed to @airnauts/airside-adapter-postgres — install that instead. No longer maintained."}},"time":{"created":"2026-06-15T12:01:01.227Z","modified":"2026-06-16T09:41:54.861Z","0.5.1":"2026-06-15T12:01:01.621Z","0.6.0":"2026-06-15T15:31:54.198Z","0.7.0":"2026-06-15T16:18:25.273Z"},"bugs":{"url":"https://github.com/Airnauts/commenting-tool/issues"},"author":{"name":"Airnauts"},"license":"MIT","homepage":"https://github.com/Airnauts/commenting-tool#readme","keywords":["comments","commenting","annotations","feedback","airnauts","postgres","postgresql","adapter"],"repository":{"url":"git+https://github.com/Airnauts/commenting-tool.git","type":"git","directory":"packages/adapter-postgres"},"description":"PostgreSQL repository adapter for the Airnauts commenting tool server.","maintainers":[{"name":"jkrzemie","email":"hello@airnauts.com"},{"name":"mateuszpaulski","email":"mateusz@airnauts.com"}],"readme":"# @airnauts/comments-adapter-postgres\n\nPostgreSQL repository adapter for the [Airnauts commenting tool](https://github.com/Airnauts/commenting-tool) server. Stores threads in a hybrid relational + `jsonb` schema; driver-agnostic via a host-supplied `query()` executor.\n\n## Installation\n\n```bash\npnpm add @airnauts/comments-adapter-postgres\n# Add the pg driver only if you use postgresRepository() or a pg.Pool executor:\npnpm add pg\n```\n\n`pg` is an optional peer dependency — not needed if you supply your own executor (e.g. Neon's `Pool`, Supabase's client).\n\n## Quick start\n\n```ts\nimport { postgresRepository } from '@airnauts/comments-adapter-postgres'\n\nconst repository = postgresRepository({\n  connectionString: process.env.DATABASE_URL!,\n})\n```\n\nPass `repository` to `createCommentsServer` from `@airnauts/comments-server` (or to `createCommentsAppRoute` / `createCommentsPagesRoute` from `@airnauts/comments-next`). The adapter connects lazily on first use and runs `ensureSchema` automatically.\n\n## API reference\n\n### `postgresRepository(opts)`\n\nOwns the connection lifecycle. Connects lazily on first use and memoizes the pool under `cacheKey` for hot-reload / warm serverless reuse.\n\n```ts\npostgresRepository({\n  connectionString: string  // PostgreSQL connection string (required)\n  cacheKey?: string         // memoization key, default \"postgres\"\n}): Repository\n```\n\n### `createPostgresRepository(opts)`\n\nLower-level factory for callers that manage their own connection. Accepts anything with a `query(text, params)` method — `pg.Pool`, Neon's `Pool`, Supabase's client, etc.\n\n```ts\nimport { Pool } from '@neondatabase/serverless'\nimport { createPostgresRepository, ensureSchema } from '@airnauts/comments-adapter-postgres'\n\nconst pool = new Pool({ connectionString: process.env.DATABASE_URL! })\nawait ensureSchema(pool)\nconst repository = createPostgresRepository({ sql: pool })\n```\n\n> **Note:** Neon's pure-HTTP tagged-template client does not satisfy the `query(text, params)` shape — use Neon's `Pool` instead.\n\n### `ensureSchema(sql)`\n\nCreates the `comments_threads` and `comments_attachments` tables and their indexes with `CREATE … IF NOT EXISTS` — safe to call on every startup. Use this when managing your own executor; `postgresRepository` calls it automatically.\n\nProduction teams that prefer managed migrations can run the equivalent DDL through their own tooling instead.\n\n### `SqlExecutor` type\n\n```ts\nimport type { SqlExecutor } from '@airnauts/comments-adapter-postgres'\n// { query(text: string, params?: unknown[]): Promise<{ rows: unknown[] }> }\n```\n\nImplement this interface to plug in any Postgres-compatible driver.\n\n## Peer dependencies & requirements\n\n| Peer | Required | Notes |\n|---|---|---|\n| `pg` | Optional (^8.11.0) | Only needed for `postgresRepository()` or a `pg.Pool` executor |\n\n- Node.js ≥ 18\n- PostgreSQL ≥ 14\n\n## Related packages\n\n- **`@airnauts/comments-server`** — defines the `Repository` interface\n- **`@airnauts/comments-adapter-mongo`** — MongoDB alternative\n- **`@airnauts/comments-adapter-memory`** — in-memory adapter for dev/tests\n- **`@airnauts/comments-next`** — Next.js integration that accepts this adapter\n\n## License\n\nMIT © Airnauts\n","readmeFilename":"README.md"}