Skip to content

@smplcty/db

A handful of thin helpers over node-postgres. An env-driven Pool factory, connection-string resolution, checkout and transaction wrappers, a parameterized UPDATE/upsert generator, and friendly Postgres error messages. It does not reinvent pg — bring your own as a peer dependency.

Thin over pg

No ORM, no query builder, no magic. Every helper is a few lines you’d otherwise write by hand on every service.

Schema-agnostic

Knows nothing about your tables, sessions, or RLS. SQL generators take the table and columns as input; transaction wrappers set no session variables.

Safe upserts

UPDATE-then-INSERT-where-not-exists — never ON CONFLICT, which burns serial sequence values. Bulk recordsets in a single round-trip.

Typed errors

Map Postgres SQLSTATE codes to user-facing messages and HTTP statuses without restating the copy in every service.