stable

postgres

PostgreSQL adapter for noy-db — encrypted-envelope KV in a single table with a jsonb column, atomic CAS via UPDATE ... WHERE v = ? RETURNING id.

@noy-db/to-postgres · pnpm add @noy-db/to-postgres Encrypted-envelope KV in a single Postgres table.

Shaperecord
Atomic CAS✓
Localityremote
Speedmedium
Persistencedurable

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: true via UPDATE … 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