{"id":40636,"library":"baby-orm","title":"Baby ORM","description":"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.","status":"active","version":"1.0.38","language":"javascript","source_language":"en","source_url":"https://github.com/wecrea/baby-orm","tags":["javascript","orm","database","postgres"],"install":[{"cmd":"npm install baby-orm","lang":"bash","label":"npm"},{"cmd":"yarn add baby-orm","lang":"bash","label":"yarn"},{"cmd":"pnpm add baby-orm","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package uses CommonJS only and does not support ESM imports. Use require() in Node.js.","wrong":"import { Query } from 'baby-orm';","symbol":"Query","correct":"const { Query } = require('baby-orm');"},{"note":"CommonJS require is required. ORM.model() is the primary entry point for model operations.","wrong":"import { ORM } from 'baby-orm';","symbol":"ORM","correct":"const { ORM } = require('baby-orm');"},{"note":"Helpers is a named export, not default. ESM import will fail.","wrong":"import Helpers from 'baby-orm';","symbol":"Helpers","correct":"const { Helpers } = require('baby-orm');"}],"quickstart":{"code":"const { Query, ORM } = require('baby-orm');\n\n// Using Query directly\nlet query = new Query('SELECT * FROM users WHERE email = $1', ['test@example.com']);\nquery.execute()\n  .then(result => console.log(result))\n  .catch(err => console.error(err));\n\n// Using ORM model\nlet User = ORM.model('user');\nUser.create({\n  firstname: 'Jane',\n  lastname: 'Doe',\n  email: 'jane.doe@example.com'\n})\n  .then(result => console.log('User created', result))\n  .catch(err => console.error(err));","lang":"javascript","description":"Demonstrates basic Query execution and ORM model usage with create operation."},"warnings":[{"fix":"Set environment variables before requiring baby-orm, e.g., process.env.PGHOST = 'localhost';","message":"All database configuration must be set via environment variables (PGUSER, PGHOST, etc.) or .env file. There is no programmatic configuration API.","severity":"gotcha","affected_versions":"*"},{"fix":"Ensure model file exports an object with config and fields properties. See documentation for exact schema.","message":"Model files must export a plain object matching a specific structure (config, fields, methods). Improper exports will cause silent failures or crashes.","severity":"gotcha","affected_versions":"*"},{"fix":"Add columns to your migration or table schema manually before enabling these features.","message":"Timestamps and soft delete require corresponding columns (created_at, updated_at, deleted_at) in your database table. They do not create columns automatically.","severity":"gotcha","affected_versions":"*"},{"fix":"Set BABYORM_DATABASE_DIR to the directory where your migration files reside.","message":"Migrations directory path must be configured via BABYORM_DATABASE_DIR environment variable. Default is 'database' but may not exist.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'1.0.38':13 'activerecord':22 'activerecord-styl':21 'appear':69 'autoincr':34 'babi':1,3,55 'builder':19 'cli':40 'compar':47 'creat':43 'databas':76 'delet':31 'develop':68 'focus':57 'heavier':49 'id':37 'includ':39 'infrequ':72 'javascript':74 'layer':25 'lightweight':7 'like':51 'medium':66 'migrat':46 'minim':59 'model':24 'node.js':8 'orm':2,4,9,50,56,75 'postgr':77 'postgresql':11 'project':67 'provid':15 'queri':18 'releas':73 'run':45 'sequel':52 'simpl':17 'slow':70 'small':64 'soft':30 'straightforward':61 'string':36 'style':23 'support':27 'timestamp':29 'tool':41 'typeorm':54 'usag':62 'valid':32 'version':12","created_at":"2026-06-04T18:48:32.551104+00:00","updated_at":"2026-06-04T18:48:32.551104+00:00","problems":[{"fix":"Run 'npm install baby-orm --save' in your project root.","cause":"Package not installed or installed globally instead of locally.","error":"Error: Cannot find module 'baby-orm'"},{"fix":"Use 'const { ORM } = require(\"baby-orm\");'","cause":"Incorrect import - likely using ESM import instead of CommonJS require.","error":"TypeError: ORM.model is not a function"},{"fix":"Set PGHOST to your PostgreSQL host (e.g., 'localhost' or an IP address).","cause":"Missing or incorrect PGHOST environment variable.","error":"Error: getaddrinfo ENOTFOUND"},{"fix":"Create a migration or manually create the table in PostgreSQL before using the model.","cause":"The database table for the model does not exist yet.","error":"Error: relation \"users\" does not exist"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/wecrea/baby-orm","github":"https://github.com/wecrea/baby-orm","docs":null,"changelog":null,"pypi":null,"npm":"baby-orm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}