postgres
Implementation of postgres.js. There is no default interpreter because it requires a live database connection.
You construct one by calling serverInterpreter(client, baseInterpreter) with a connected client. The playground examples on this site use wasmPgInterpreter, backed by PGLite, an in-browser WASM build of Postgres.
import { postgres, serverInterpreter, wrapPostgresJs } from "@mvfm/plugin-postgres";
import postgresJs from "postgres";
// 1. Create a postgres.js client
const sql = postgresJs("postgres://user:pass@localhost:5432/mydb");
const client = wrapPostgresJs(sql);
// 2. Build a base interpreter for sub-expressions
const baseInterp = defaults(app);
// 3. Create the postgres interpreter
const pgInterp = serverInterpreter(client, baseInterp);
// 4. Merge and run
await fold(
{ ...baseInterp, ...pgInterp },
injectInput(prog, { userId: 42 })
);