Registry / database / node-pg-orm

node-pg-orm

JSON →
library1.0.15jsnpmunverified

A minimal ORM for Node.js and PostgreSQL that provides a simple mapping layer between JavaScript objects and database tables. Current version 1.0.15, with no established release cadence (appears maintained by a single developer). Key differentiators: lightweight, no dependencies, straightforward API with support for basic CRUD operations, finders, and aggregations. However, it lacks migration support, query building flexibility, and active maintenance compared to alternatives like Sequelize or Knex. Suitable for small projects needing quick PostgreSQL integration.

npm install node-pg-orm
INSTALL
IMPORT
SIG · NODE-PG-ORM
N
node-pg-orm
databasejavascriptv1.0.15
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import Orm from 'node-pg-orm'
const Orm = require('node-pg-orm')
Package is ESM-only from the start; CommonJS require will fail.
Orm
const { Orm } = require('node-pg-orm')
import { Orm } from 'node-pg-orm'
Named export Orm is available for CommonJS, but default import is CommonJS-incompatible. For ESM, use default import.
QueryResult
import { QueryResult } from 'node-pg-orm'
TypeScript types are not bundled; check @types/node-pg-orm if exists.

Connects to PostgreSQL, defines a model, and performs basic CRUD operations.

import Orm from 'node-pg-orm'; const config = { user: process.env.PG_USER ?? 'postgres', host: process.env.PG_HOST ?? 'localhost', database: process.env.PG_DATABASE ?? 'test', password: process.env.PG_PASSWORD ?? '', port: parseInt(process.env.PG_PORT ?? '5432'), }; async function main() { const orm = new Orm(config); await orm.authenticate(); console.log('Connected'); // Define a model const User = orm.define('users', { id: { type: 'serial', primaryKey: true }, name: { type: 'varchar', length: 255 }, email: { type: 'varchar', length: 255 } }); // Create const user = await User.create({ name: 'Alice', email: 'alice@example.com' }); console.log('Created:', user); // Find const users = await User.findAll(); console.log('All users:', users); await orm.close(); } main().catch(console.error);
Debug
Known issues
gotchaThe package is not actively maintained; last update over a year ago. Use at your own risk.
fix
Consider migration to a maintained ORM like Sequelize or Prisma.
affects: <=1.0.15
gotchaNo TypeScript type definitions are provided. You may encounter type errors.
fix
Install @types/node-pg-orm if available, or define your own types.
affects: >=0.0.0
gotchaThe package relies on the 'pg' driver but does not include it as a dependency. You must install 'pg' separately.
fix
Run 'npm install pg' alongside node-pg-orm.
affects: >=0.0.0
breakingEngine requirement node >=8.9 (very old). May not work on newer Node versions due to API changes.
fix
Use Node 14 or lower, or switch to a modern ORM.
affects: <=1.0.15
Errors
Common errors & fixes
Cannot find module 'pg'
The pg driver is not installed as a peer dependency.
fix
Run 'npm install pg' to add PostgreSQL driver.
Error: listen EADDRINUSE :::5432
Default PostgreSQL port is already in use by another instance.
fix
Change the port in config or stop the other PostgreSQL service.
Upgrade
Version history
1.0.15latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
node-pg-orm — npm install node-pg-orm · libregistry