postgres
@noy-db/to-postgres·pnpm add @noy-db/to-postgresEncrypted-envelope KV in a single Postgres table.
| Shape | record |
| Atomic CAS | ✓ |
| Locality | remote |
| Speed | medium |
| Persistence | durable |
What it does
Stores each record's ciphertext envelope in a jsonb column of a single table.
Works with any duck-typed client exposing query(sql, params) → { rows }: pg
(node-postgres), @vercel/postgres, @neondatabase/serverless, a raw drizzle-orm
pool, or postgres.js via a light shim.
Notes
casAtomic: trueviaUPDATE … WHERE v = ? RETURNING id.- Record shape, one row per record.
- Factory:
toPostgres(options: PostgresStoreOptions).
Store-locator descriptor
See store-locator descriptors for the general model.
kind: 'postgres', class: 'cloud'. address is { database?, schema?, table? }: table maps to tableName; database and schema are
identity-only, not consumed by the factory — the connection already carries
them. options is { autoMigrate? }. binding.client is required —
this store has no client library of its own; resolve() without it throws.
import { postgresStoreDescriptor, registerPostgresStore } from '@noy-db/to-postgres'
const descriptor = postgresStoreDescriptor({ database: 'app', schema: 'public', table: 'noydb_envelopes' })
See also
- to-* family
- mysql
- supabase — a thin factory over this store