Skip to content

PostgreSQL Node

Self-contained provider for PostgreSQL in Node.js. ESM-only.

  • Driver: pg
  • Compiler: SQL generation via @jsorm/compiler (postgresDialect)
  • Connection manager: connection pool
  • Execute: CRUD and aggregation
  • Schema sync: creates missing tables

  • Node.js 22+ (uses @jsorm/compiler with sync node:crypto HMAC cursors)

Param Type Default
url string "postgresql://localhost:5432/postgres"
database string — (url path)
syncSchema boolean false
cursorSecret string Required for .cursor()
ssl boolean | object undefined (auto-negotiate)
max number 20
idleTimeoutMillis number 10000
connectionTimeoutMillis number 5000

SSL: By default, pg negotiates SSL automatically. To force SSL in production: ssl: { rejectUnauthorized: true }.

Pool: Default limit of 20 connections.

import { createPostgresNodeProvider } from "@jsorm/provider-pg-node";
createPostgresNodeProvider(models, { url: "postgresql://localhost:5432/mydb" });
import { defineConfig, env } from "@jsorm/core";
export default defineConfig({
databases: {
main: {
access: "server",
provider: "postgres-node",
options: { url: env("DATABASE_URL_PG") },
},
},
});
.env
DATABASE_URL_PG=postgresql://user:pass@localhost:5432/mydb

Independent of core and client.