Registry / database / light-orm

light-orm

JSON →
library0.1.4jsnpmunverified

Super simple ORM wrapper for Node.js relational databases (MySQL, PostgreSQL, MS SQL Server, etc.) that does not depend on any specific driver. Version 0.1.4 is the latest release, with no known update cadence. It provides a minimal ActiveRecord-like API with Collection and Model classes, allowing raw SQL queries or simple condition-based finders. Unlike full-featured ORMs like Sequelize or TypeORM, it offers no schema migrations, associations, or promise support – it's callback-based and relies on the user to supply a driver that implements the node-mysql query interface.

npm install light-orm
INSTALL
IMPORT
SIG · LIGHT-ORM
L
light-orm
databasejavascriptv0.1.4
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.

lightOrm
import lightOrm from 'light-orm';
const lightOrm = require('light-orm');
The package is CommonJS only (no ESM). Use require() as shown in the examples, not import.
Collection
const Collection = lightOrm.Collection;
import { Collection } from 'light-orm';
Collection is a property of the default export, not a named export.
driver
lightOrm.driver = mysql.createConnection(...);
import { driver } from 'light-orm';
The driver is set as a property on the imported object, not imported separately.

Connects to MySQL using node-mysql driver, creates a Collection for 'author' table, and retrieves a record by ID.

const mysql = require('mysql'); const lightOrm = require('light-orm'); // Set driver (must implement query method) lightOrm.driver = mysql.createConnection({ host: 'localhost', user: 'user', password: process.env.DB_PASSWORD ?? '', database: 'test' }); lightOrm.driver.connect(); // Create a collection const AuthorCollection = new lightOrm.Collection('author'); // Find one AuthorCollection.findOne({ id: 1 }, (err, model) => { if (err) console.error(err); else console.log(model.getAll()); });
Debug
Known issues
breakinglight-orm does not support Promises or async/await. All operations are callback-based.
fix
Wrap callbacks manually or switch to a modern ORM like Sequelize or TypeORM.
affects: >=0.0.0
gotchaThe driver property must be set to an object with a query method matching the node-mysql signature (query(string, callback)). Other drivers may not work.
fix
Ensure your driver implements the exact signature: query(sql, (err, rows, fields) => {}).
affects: >=0.0.0
gotchaNo TypeScript definitions are provided. This package is JavaScript only.
fix
Create your own typing or use with @types/light-orm (which does not exist).
affects: >=0.0.0
gotchaThe package has not been updated since 2014 and is effectively abandoned. No security patches or bug fixes.
fix
Consider migrating to a maintained ORM.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: lightOrm.driver.query is not a function
The driver object assigned to lightOrm.driver does not have a query method.
fix
Make sure the driver has a `query` method that accepts (sql, callback) as arguments.
Cannot find module 'light-orm'
The package is not installed or the import path is incorrect.
fix
Run `npm install light-orm` and use `require('light-orm')`.
Model.getAll is not a function
The callback returns a model object that does not have getAll(). This may happen if the query failed but error was not handled.
fix
Always check the error parameter first: if (err) return console.error(err);
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
Resources
light-orm — npm install light-orm · libregistry