@meshqljs/postgres (@meshql/postgres)
Postgres helper for MeshQL. Builds parameterised SELECT statements from a join plan; you supply the connection.
Install
Section titled “Install”npm install @meshqljs/postgres @meshqljs/core pgnpm i pgnpx jsr add @meshql/postgres @meshql/corenpm i pgPublished on npm as @meshqljs/postgres and JSR as @meshql/postgres.
Example
Section titled “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;});import { createMesh, type MeshSchema } from "@meshql/core";import { buildSelectSql } from "@meshql/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.