Introduction
@smplcty/db is a handful of tiny TypeScript helpers for
pg (node-postgres). It’s the code you’d
otherwise copy between services: an env-driven Pool factory, a
connection-string resolver, checkout/transaction wrappers, a
parameterized UPDATE/upsert generator, and friendly Postgres error
messages.
What it is not
Section titled “What it is not”- Not an ORM or query builder. You write SQL. The only SQL it generates is the mechanical UPDATE/INSERT-upsert pattern, from a field list you provide.
- Not a
pgreplacement.pgis a peer dependency — you install it and pick the version. Every helper takes apg.PoolorPoolClient. - Not coupled to your schema. No helper assumes a table, column, or
session variable exists. SQL generators take the table and columns as
arguments; the transaction wrapper sets no session GUCs (layer RLS on
top, e.g. with
@smplcty/auth).
Design principles
Section titled “Design principles”- Stay thin over
pg. If a feature belongs inpg, it belongs inpg. - Simplicity over cleverness. The best change is usually the one that removes code.
- Behavioral tests only. The suite runs against a real Postgres — no mocks.
Continue to Installation.