Registry / database / baby-orm

baby-orm

JSON →
library1.0.38jsnpmunverified

Baby ORM is a lightweight Node.js ORM for PostgreSQL, version 1.0.38. It provides a simple Query builder, an ActiveRecord-style model layer with support for timestamps, soft deletes, validations, and autoincrement or string IDs. It includes CLI tools for creating and running migrations. Compared to heavier ORMs like Sequelize or TypeORM, Baby ORM focuses on minimalism and straightforward usage for small to medium projects. Development appears slow with infrequent releases.

npm install baby-orm
INSTALL
IMPORT
SIG · BABY-ORM
B
baby-orm
databasejavascriptv1.0.38
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.

Query
const { Query } = require('baby-orm');
import { Query } from 'baby-orm';
This package uses CommonJS only and does not support ESM imports. Use require() in Node.js.
ORM
const { ORM } = require('baby-orm');
import { ORM } from 'baby-orm';
CommonJS require is required. ORM.model() is the primary entry point for model operations.
Helpers
const { Helpers } = require('baby-orm');
import Helpers from 'baby-orm';
Helpers is a named export, not default. ESM import will fail.

Demonstrates basic Query execution and ORM model usage with create operation.

const { Query, ORM } = require('baby-orm'); // Using Query directly let query = new Query('SELECT * FROM users WHERE email = $1', ['test@example.com']); query.execute() .then(result => console.log(result)) .catch(err => console.error(err)); // Using ORM model let User = ORM.model('user'); User.create({ firstname: 'Jane', lastname: 'Doe', email: 'jane.doe@example.com' }) .then(result => console.log('User created', result)) .catch(err => console.error(err));
Debug
Known issues
gotchaAll database configuration must be set via environment variables (PGUSER, PGHOST, etc.) or .env file. There is no programmatic configuration API.
fix
Set environment variables before requiring baby-orm, e.g., process.env.PGHOST = 'localhost';
affects: *
gotchaModel files must export a plain object matching a specific structure (config, fields, methods). Improper exports will cause silent failures or crashes.
fix
Ensure model file exports an object with config and fields properties. See documentation for exact schema.
affects: *
gotchaTimestamps and soft delete require corresponding columns (created_at, updated_at, deleted_at) in your database table. They do not create columns automatically.
fix
Add columns to your migration or table schema manually before enabling these features.
affects: *
gotchaMigrations directory path must be configured via BABYORM_DATABASE_DIR environment variable. Default is 'database' but may not exist.
fix
Set BABYORM_DATABASE_DIR to the directory where your migration files reside.
affects: *
Errors
Common errors & fixes
Error: Cannot find module 'baby-orm'
Package not installed or installed globally instead of locally.
fix
Run 'npm install baby-orm --save' in your project root.
TypeError: ORM.model is not a function
Incorrect import - likely using ESM import instead of CommonJS require.
fix
Use 'const { ORM } = require("baby-orm");'
Error: getaddrinfo ENOTFOUND
Missing or incorrect PGHOST environment variable.
fix
Set PGHOST to your PostgreSQL host (e.g., 'localhost' or an IP address).
Error: relation "users" does not exist
The database table for the model does not exist yet.
fix
Create a migration or manually create the table in PostgreSQL before using the model.
Upgrade
Version history
1.0.38latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
baby-orm — npm install baby-orm · libregistry