@meshqljs/postgres
v0.7.0
Published
MeshQL Postgres helper - build parameterized SELECT statements from a join plan
Readme
@meshql/postgres
Postgres helper for MeshQL. Builds parameterised SELECT statements from a join plan; you supply the connection.
Install
npm install @meshqljs/postgres @meshqljs/core pg
# or
npx jsr add @meshql/postgres @meshql/core
npm i pgPublished on npm as @meshqljs/postgres and JSR as @meshql/postgres.
Example
import { createMesh, type MeshSchema } from "@meshqljs/core";
import { buildSelectSql } from "@meshqljs/postgres";
import { Pool } from "pg";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const schema: MeshSchema = { /* … */ };
const mesh = createMesh(schema);
mesh.resolve("user", async (plan) => {
const { sql, params } = buildSelectSql(plan, schema);
const result = await pool.query(sql, params);
return result.rows;
});JSR imports: @meshql/core, @meshql/postgres.
See also @meshql/sqlite.
