Registry / database / febs-db

febs-db

JSON →
library1.9.15jsnpmunverified

febs-db is an ORM library for Node.js (v6+) supporting MySQL and MSSQL, based on citong-db@1.5.3 (now unmaintained). It provides a table-based abstraction with full CRUD operations, transaction support with isolation levels, stored procedures, and join queries. The library is TypeScript-compatible (ships types) and uses ES6+ features. Version 1.9.15 is the latest; v0.0.3 and earlier are incompatible. Key differentiators: combined primary key support, custom auto-increment primary key, column name mapping, and a condition builder with type checking. Release cadence appears sporadic; maintenance is minimal.

npm install febs-db
INSTALL
IMPORT
SIG · FEBS-DB
F
febs-db
databasejavascriptv1.9.15
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.

database
import { database } from 'febs-db'
const database = require('febs-db').database
ESM import with named export; CommonJS require works but TypeScript prefers named import.
tablebase
import { tablebase } from 'febs-db'
const { TableBase } = require('febs-db')
Name is all lowercase; tablebase is the class, not TableBase.
dataType
import { dataType } from 'febs-db'
import DataType from 'febs-db'
dataType is a named export, not default.
condition
import { condition } from 'febs-db'
condition is a class used via tablebase.condition.
exception
import { exception } from 'febs-db'
const { Exception } = require('febs-db')
Export is lowercase 'exception', not 'Exception'.

Shows full CRUD with custom table class, condition builder, transaction, and raw query.

import { database, tablebase, dataType, condition } from 'febs-db'; // Define a table class extending tablebase class UserTable extends tablebase { constructor(db) { super(db, 'user'); // Define columns this.regColumn({ id: { type: dataType.INTEGER, autoIncr: true }, name: { type: dataType.STRING, length: 50 }, email: { type: dataType.STRING, length: 100 }, created_at: { type: dataType.TIMESTAMP } }); this.regPrimaryKey('id'); } } // Connect to MySQL const db = new database({ type: 'mysql', host: process.env.DB_HOST ?? 'localhost', port: 3306, user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: 'test' }); const userTable = new UserTable(db); async function main() { // Add a new user const newId = await userTable.add({ name: 'Alice', email: 'alice@example.com', created_at: new Date() }); console.log('Inserted user id:', newId); // Query users const users = await userTable.select(userTable.condition().equal('name', 'Alice')); console.log('Found users:', users); // Update await userTable.update({ email: 'alice@newdomain.com' }, userTable.condition().equal('id', newId)); // Delete await userTable.remove(userTable.condition().equal('id', newId)); // Transaction await db.transaction(async () => { await userTable.add({ name: 'Bob', email: 'bob@example.com' }); }); // Raw query const rows = await db.exec('SELECT * FROM user'); console.log(rows); } main().catch(console.error);
Debug
Known issues
breakingv0.0.3 and earlier APIs are incompatible; migration from those versions requires rewriting.
fix
Upgrade to v1.x and refactor code using the new API as described in README-v0.0.3.md.
affects: <=0.0.3
gotchaMySQL must use InnoDB engine; febs-db does not support MyISAM or other engines.
fix
Use ENGINE=InnoDB when creating tables.
affects: >=1.0.0
deprecatedcitong-db@1.5.3 is the base but no longer maintained; febs-db has diverged.
fix
Use febs-db directly; do not rely on citong-db API compatibility.
affects: >=1.0.0
gotchaThe condition class is accessed via tablebase.condition() instance method, not imported directly.
fix
Use userTable.condition() to get a condition object.
affects: >=1.0.0
gotchaException codes are properties of the exception class (e.g., exception.DB_SqlException). Comparison uses exception.DB_SqlException, not string.
fix
Use if (e.code === exception.DB_SqlException).
affects: >=1.0.0
gotchadataType fields like dataType.INTEGER may require explicit length or autoIncr options; not all types are auto-detectable.
fix
Always provide type options (length, autoIncr) when registering columns.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: tablebase is not a constructor
Trying to instantiate tablebase directly instead of subclassing it.
fix
Create a subclass: class MyTable extends tablebase { constructor(db) { super(db, 'tablename'); } }
Error: DB_SqlException: Unknown column '...' in 'where clause'
Column name used in condition does not match the registered column name.
fix
Verify column names: they must match exactly the keys used in regColumn.
Error: DB_ConneException: connect ECONNREFUSED
Database server is not running or connection parameters are incorrect.
fix
Check host, port, and ensure MySQL/MSSQL service is started.
TypeError: Cannot read property 'condition' of undefined
tablebase instance not properly initialized; or using condition() before calling super().
fix
Ensure constructor calls super(db, tablename) and that db is a valid database instance.
Upgrade
Version history
1.9.15latest on npm
Audit
Dependencies
mysqlrequiredMySQL driver for database connections
mssqloptionalMSSQL driver for database connections
Agent activity
2 hits · last 30 days
node
2
Resources