Registry / database / dborm-mysql

dborm-mysql

JSON →
library2.2.7jsnpmunverified

DbORM is a Node.js ORM for MySQL that returns promises. It requires each table to have a primary key named 'id'. Version 2.2.7 ships TypeScript types. Provides CRUD operations (add, get, getList, update, updateByIds, updateByQuery, getCount) with a map-based field conversion system. Unlike other ORMs, it uses a db2ramFieldMap for field name mapping and can handle JSON fields via textDbFieldsMap. Configuration includes connection limit, multiple statements, and error code customization. Released at an unknown cadence.

npm install dborm-mysql
INSTALL
IMPORT
SIG · DBORM-MYSQL
D
dborm-mysql
databasejavascriptv2.2.7
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.

init
const dbORM = require('dborm-mysql')({ ... })
import dbORM from 'dborm-mysql'
The default export is a factory function that takes a config object. ESM import pattern is not supported.
dao
const userDao = dbORM('tableName')
const userDao = new dbORM('tableName')
Calling the returned dbORM function with a table name returns a DAO instance. Do not use 'new'.
TypeScript usage
import type { DbORMConfig } from 'dborm-mysql'
import { DbORMConfig } from 'dborm-mysql'
Types are exported but may require importing from the package. Check package.json for type definitions.

Initializes the ORM with database config, field mapping, and performs basic CRUD operations (add, get, getList, update, getCount).

const dbORM = require('dborm-mysql')({ dbConfig: { connectionLimit: 10, database: 'test', host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '' }, db2ramFieldMap: { users: { id: 'id', name: 'name', email: 'email' } }, textDbFieldsMap: { users: ['details'] }, options: { log: false, dbCode: 733, noConvertDbCodes: [] } }); const userDao = dbORM('users'); // Add a user userDao.add({ name: 'Alice', email: 'alice@example.com', details: { age: 30 } }) .then(result => console.log('Added:', result)) .catch(err => console.error(err)); // Get user by id userDao.get(1).then(user => console.log('User:', user)); // Get list with filters userDao.getList({ department: 'qa', offset: 0, limit: 10 }) .then(list => console.log('List:', list)); // Update user userDao.update({ name: 'Bob' }, 1).then(() => console.log('Updated')); // Get count userDao.getCount({}).then(count => console.log('Count:', count));
Debug
Known issues
breakingEach table must have a primary key named 'id'
fix
Ensure your MySQL tables have an auto-increment primary key column named 'id'.
affects: >=0.0.0
deprecatedThe 'keyword' parameter in getList and updateByQuery uses a colon-separated format and may change in future versions
fix
Follow current documentation or consider migrating to newer parameter patterns if they become available.
affects: >=2.0.0
gotchaField names in db2ramFieldMap are used for both mapping and query construction; omitting a field will cause it not to be fetched or updated.
fix
Include all relevant fields in db2ramFieldMap, even if they have the same name in the database.
affects: >=0.0.0
gotchaJSON fields defined in textDbFieldsMap are automatically serialized/deserialized using JSON.stringify/JSON.parse; wrong field types will cause errors.
fix
Ensure only text/JSON columns are listed; add fields that store serialized JSON objects.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: dbORM is not a function
The require returns a factory function that must be called with a config object.
fix
const dbORM = require('dborm-mysql')({ dbConfig: {...}, ... });
Error: ER_BAD_FIELD_ERROR: Unknown column 'someField' in 'field list'
The field 'someField' is not defined in db2ramFieldMap for the table.
fix
Add the missing field to db2ramFieldMap under the correct table name.
Error: dbCode=733: Table 'test.nonexistent' doesn't exist
The table name used with dbORM() does not exist in the database.
fix
Ensure the table exists and is spelled correctly in the dbORM() call.
Upgrade
Version history
2.2.7latest on npm
Audit
Dependencies
mysqlrequiredMySQL database driver
Agent activity
8 hits · last 30 days
node
6
Resources
dborm-mysql — npm install dborm-mysql · libregistry