PostgreSQL Node
Self-contained provider for PostgreSQL in Node.js. ESM-only.
Responsibilities
Section titled “Responsibilities”- Driver: pg
- Compiler: SQL generation via @jsorm/compiler (postgresDialect)
- Connection manager: connection pool
- Execute: CRUD and aggregation
- Schema sync: creates missing tables
Requirements
Section titled “Requirements”- Node.js 22+ (uses @jsorm/compiler with sync node:crypto HMAC cursors)
ProviderOptions
Section titled “ProviderOptions”| 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" });Usage with env()
Section titled “Usage with env()”import { defineConfig, env } from "@jsorm/core";
export default defineConfig({ databases: { main: { access: "server", provider: "postgres-node", options: { url: env("DATABASE_URL_PG") }, }, },});DATABASE_URL_PG=postgresql://user:pass@localhost:5432/mydbInterchangeable
Section titled “Interchangeable”Independent of core and client.
