@waymakeros/db
v0.3.1
Published
Postgres client for apps built on Waymaker Host. Reads DATABASE_URL from the app's environment; connection and hosting details stay internal to the platform.
Maintainers
Readme
@waymakeros/db
Postgres access for apps built on Waymaker Host — the app-side equivalent of
ctx.postgres (which Ambassadors and Agents get).
import { sql } from '@waymakeros/db'
const customers = await sql`SELECT * FROM customers WHERE plan = ${plan}`
const [order] = await sql`INSERT INTO orders (customer_id) VALUES (${id}) RETURNING *`
// conventional form
import { query } from '@waymakeros/db'
const rows = await query('SELECT * FROM orders WHERE status = $1', ['open'])- You own your data. It's standard Postgres — standard SQL, portable, no lock-in.
- The vendor stays hidden. Your app imports
@waymakeros/db, never a hosting driver, so the platform can change the engine underneath without touching your app. - Connection is automatic. Reads
DATABASE_URL, injected when you connect a database to your app in Host. You never handle the connection string.
Create tables with migrations;
@waymakeros/db reads and writes data at runtime.
One rule worth knowing
Importing sql / query / db at module scope and reusing them across requests is safe —
this is a stateless HTTP client, so it holds no socket and nothing is cached across a request
boundary.
The same is not true of a connection pool. A pool held at module scope in a serverless runtime makes requests hang non-deterministically once deployed — one route returns 200, the next 500, on the same code and the same deploy. If you need an interactive transaction, open a pool inside the function that needs it and close it before returning.
