Registry / database / h-orm
library0.0.11jsnpmunverified

h-orm is a lightweight MySQL ORM for Node.js, version 0.0.11. It provides a simple promise-based API for common CRUD operations, connection pooling, and a model-based approach. Key differentiators include minimal configuration, support for like queries, and automatic status field handling for soft deletes. The package has a low release cadence and is suitable for small to medium projects.

npm install h-orm
INSTALL
IMPORT
SIG · H-ORM
H
h-orm
databasejavascriptv0.0.11
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
const horm = require('h-orm');
import horm from 'h-orm'; // No default ESM export
h-orm is CJS-only; use require().
model
const horm = require('h-orm'); const Model = horm.model('table', schema);
import { model } from 'h-orm'; // Named import not supported
model() is a method on the default export, not a named export.
connect
const horm = require('h-orm'); horm.connect(config);
import connect from 'h-orm/connect'; // No subpath exports
connect() is a method on the default export, called directly.

Shows connection setup, model definition, and CRUD operations: find, create, update, delete.

const horm = require('h-orm'); horm.connect({ host: process.env.DB_HOST || '127.0.0.1', port: process.env.DB_PORT || '3306', database: process.env.DB_NAME || 'test', user: process.env.DB_USER || 'root', password: process.env.DB_PASS || '', debug: true }); const UserModel = horm.model('users', { name: String, age: Number }); (async () => { const all = await UserModel(); console.log('All users:', all); const created = await UserModel().create({ name: 'Alice', age: 30 }); console.log('Created:', created); const found = await UserModel().find(1); console.log('Found by id 1:', found); const updated = await UserModel().update({ age: 31 }, { name: 'Alice' }); console.log('Updated:', updated); const deleted = await UserModel().delete({ age: 31 }); console.log('Deleted count:', deleted); })();
Debug
Known issues
gotchaModel fields are defined with JavaScript constructors (String, Number) but type enforcement is loose; non-matching types may be stored without validation.
fix
Pre-validate data before passing to create/update operations.
affects: >=0.0.0
gotchaThe `model()` function returns an instance, but actual querying is done by calling the instance as a function (e.g., `Model()`) or chaining methods like `Model().find(1)`. Omitting the empty call `()` will return the function itself, not execute the query.
fix
Always call the model instance as a function or chain methods: `const results = await MyModel().find(1);`
affects: >=0.0.0
gotchaThe `delete()` method with an object argument performs a hard delete by default, not a soft delete. Soft delete (setting a status field) requires configuring `exInfo.status`.
fix
Call `model('table', schema, { status: 'active' })` to enable soft delete; then `delete()` will set `active=0` instead of removing the row.
affects: >=0.0.0
deprecatedThe package has not been updated since version 0.0.11 (released 2020). It relies on an older version of the mysql driver and may have compatibility issues with newer Node.js versions.
fix
Consider migrating to an actively maintained ORM like Sequelize or TypeORM.
affects: <=0.0.11
Errors
Common errors & fixes
Error: Cannot find module 'mysql'
h-orm has a peer dependency on the 'mysql' package, which is not automatically installed.
fix
Run: npm install mysql
TypeError: hormInstance().find is not a function
Forgot to call the model instance as a function. Example: `const results = await MyModel().find(1);` but wrote `results = await MyModel.find(1);`.
fix
Use `Model().find(1)` (with parentheses after Model).
Error: ER_BAD_FIELD_ERROR: Unknown column 'status' in 'where clause'
Using soft delete feature without defining the status field in the schema or table.
fix
Add the status field to the schema: `horm.model('table', { status: Number, ...otherFields })` and ensure the table has the column.
Error: Connection lost: The server closed the connection.
Connection pool idle timeout or network issue. h-orm's pool may not auto-reconnect.
fix
Increase pool limit or implement custom reconnection logic. The package does not handle reconnections automatically.
Upgrade
Version history
0.0.11latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
packageh-orm
h-orm — npm install h-orm · libregistry