Registry / database / sqldb-orm

sqldb-orm

JSON →
library1.1.0jsnpmunverified

A minimal SQL ORM supporting MySQL and SQLite3. Current stable version is 1.1.0. Provides simple CRUD operations, pagination, and table introspection. Designed for lightweight use cases where full-featured ORMs like Sequelize or TypeORM are overkill. Release cadence is unknown; the package appears to be in maintenance mode with no recent updates. Key differentiator: minimal API with automatic table discovery.

npm install sqldb-orm
INSTALL
IMPORT
SIG · SQLDB-ORM
S
sqldb-orm
databasejavascriptv1.1.0
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 orm = require('sqldb-orm');
import orm from 'sqldb-orm';
Package uses CommonJS exports, not ESM. Use require() instead of import.
getClass
let sqlDal = await orm.getClass('mysql', config, 'tb_user', true);
let sqlDal = new orm.getClass('mysql', config, 'tb_user', true);
getClass is an async factory method, not a constructor. Must be called with await.
findAll
let list = await sqlDal.findAll();
let list = sqlDal.findAll();
All data access methods return Promises. Must be awaited or used with .then().

Connect to MySQL, get ORM class for table 'tb_user', and fetch all records.

const orm = require('sqldb-orm'); const config = require('./mysql-config.js'); async function main() { const sqlDal = await orm.getClass('mysql', config, 'tb_user', true); const users = await sqlDal.findAll(); console.log(users); } main().catch(console.error);
Debug
Known issues
gotchaThe fourth argument to getClass (autoCreateTable) is a boolean that may cause table creation if true, which could overwrite existing tables.
fix
Set the fourth argument to false if you only want to use existing tables.
affects: >=1.0.0
gotchaSQLite config must be a file path string, not an object. Passing an object for SQLite will cause runtime error.
fix
For SQLite, pass the database file path as a string: orm.getClass('sqlite3', './test.db3', 'tb_user', true)
affects: >=1.0.0
breakingVersion 1.1.0 may have changed the behavior of findOne: it might return an array instead of a single object. Not documented clearly.
fix
Always treat results from findOne as an array and take the first element if needed.
affects: 1.1.0
Errors
Common errors & fixes
Error: Cannot find module 'sqlite3'
The sqlite3 driver is not installed as a dependency, or the SQLite config path is wrong.
fix
Install sqlite3: npm install sqlite3 --save
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server
MySQL server uses caching_sha2_password (MySQL 8+ default), but the mysql npm package may not support it.
fix
Run: ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; or use mysql2 package instead of mysql.
TypeError: orm.getClass is not a function
Using import instead of require, or the package is not installed correctly.
fix
Use require('sqldb-orm') and ensure package is installed: npm install sqldb-orm
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
mysqloptionalMySQL database driver for MySQL connections
sqlite3optionalSQLite3 database driver for SQLite connections
Agent activity
15 hits · last 30 days
node
12
Meta
1
OpenAI (training)
1
Resources
sqldb-orm — npm install sqldb-orm · libregistry