{"id":42752,"library":"febs-db","title":"febs-db","description":"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.","status":"maintenance","version":"1.9.15","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/brainpoint/febs-db","tags":["javascript","mysql","mssql","sqlserver","sqlite","postgresql","oracle","sybase","sql","typescript"],"install":[{"cmd":"npm install febs-db","lang":"bash","label":"npm"},{"cmd":"yarn add febs-db","lang":"bash","label":"yarn"},{"cmd":"pnpm add febs-db","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"MySQL driver for database connections","package":"mysql","optional":false},{"reason":"MSSQL driver for database connections","package":"mssql","optional":true}],"imports":[{"note":"ESM import with named export; CommonJS require works but TypeScript prefers named import.","wrong":"const database = require('febs-db').database","symbol":"database","correct":"import { database } from 'febs-db'"},{"note":"Name is all lowercase; tablebase is the class, not TableBase.","wrong":"const { TableBase } = require('febs-db')","symbol":"tablebase","correct":"import { tablebase } from 'febs-db'"},{"note":"dataType is a named export, not default.","wrong":"import DataType from 'febs-db'","symbol":"dataType","correct":"import { dataType } from 'febs-db'"},{"note":"condition is a class used via tablebase.condition.","wrong":"","symbol":"condition","correct":"import { condition } from 'febs-db'"},{"note":"Export is lowercase 'exception', not 'Exception'.","wrong":"const { Exception } = require('febs-db')","symbol":"exception","correct":"import { exception } from 'febs-db'"}],"quickstart":{"code":"import { database, tablebase, dataType, condition } from 'febs-db';\n\n// Define a table class extending tablebase\nclass UserTable extends tablebase {\n  constructor(db) {\n    super(db, 'user');\n    // Define columns\n    this.regColumn({\n      id: { type: dataType.INTEGER, autoIncr: true },\n      name: { type: dataType.STRING, length: 50 },\n      email: { type: dataType.STRING, length: 100 },\n      created_at: { type: dataType.TIMESTAMP }\n    });\n    this.regPrimaryKey('id');\n  }\n}\n\n// Connect to MySQL\nconst db = new database({\n  type: 'mysql',\n  host: process.env.DB_HOST ?? 'localhost',\n  port: 3306,\n  user: process.env.DB_USER ?? 'root',\n  password: process.env.DB_PASS ?? '',\n  database: 'test'\n});\n\nconst userTable = new UserTable(db);\n\nasync function main() {\n  // Add a new user\n  const newId = await userTable.add({ name: 'Alice', email: 'alice@example.com', created_at: new Date() });\n  console.log('Inserted user id:', newId);\n\n  // Query users\n  const users = await userTable.select(userTable.condition().equal('name', 'Alice'));\n  console.log('Found users:', users);\n\n  // Update\n  await userTable.update({ email: 'alice@newdomain.com' }, userTable.condition().equal('id', newId));\n\n  // Delete\n  await userTable.remove(userTable.condition().equal('id', newId));\n\n  // Transaction\n  await db.transaction(async () => {\n    await userTable.add({ name: 'Bob', email: 'bob@example.com' });\n  });\n\n  // Raw query\n  const rows = await db.exec('SELECT * FROM user');\n  console.log(rows);\n}\n\nmain().catch(console.error);","lang":"typescript","description":"Shows full CRUD with custom table class, condition builder, transaction, and raw query."},"warnings":[{"fix":"Upgrade to v1.x and refactor code using the new API as described in README-v0.0.3.md.","message":"v0.0.3 and earlier APIs are incompatible; migration from those versions requires rewriting.","severity":"breaking","affected_versions":"<=0.0.3"},{"fix":"Use ENGINE=InnoDB when creating tables.","message":"MySQL must use InnoDB engine; febs-db does not support MyISAM or other engines.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use febs-db directly; do not rely on citong-db API compatibility.","message":"citong-db@1.5.3 is the base but no longer maintained; febs-db has diverged.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Use userTable.condition() to get a condition object.","message":"The condition class is accessed via tablebase.condition() instance method, not imported directly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use if (e.code === exception.DB_SqlException).","message":"Exception codes are properties of the exception class (e.g., exception.DB_SqlException). Comparison uses exception.DB_SqlException, not string.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always provide type options (length, autoIncr) when registering columns.","message":"dataType fields like dataType.INTEGER may require explicit length or autoIncr options; not all types are auto-detectable.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.5.3':23 '1.9.15':60 'abstract':32 'appear':93 'auto':77 'auto-incr':76 'base':18,31 'builder':87 'cadenc':92 'check':90 'citong':21 'citong-db':20 'column':81 'combin':71 'compat':52 'condit':86 'crud':35 'custom':75 'db':3,6,22 'differenti':70 'earlier':66 'es6':57 'featur':58 'feb':2,5 'febs-db':1,4 'full':34 'incompat':68 'increment':78 'isol':40 'javascript':98 'join':45 'key':69,73,80 'latest':63 'level':41 'librari':10,48 'mainten':95 'map':83 'minim':97 'mssql':17,100 'mysql':15,99 'name':82 'node.js':12 'oper':36 'oracl':104 'orm':9 'postgresql':103 'primari':72,79 'procedur':43 'provid':27 'queri':46 'releas':91 'ship':53 'sporad':94 'sql':106 'sqlite':102 'sqlserver':101 'store':42 'support':14,38,74 'sybas':105 'tabl':30 'table-bas':29 'transact':37 'type':54,89 'typescript':51,107 'typescript-compat':50 'unmaintain':25 'use':56 'v0.0.3':64 'v6':13 'version':59","created_at":"2026-06-05T16:56:30.022587+00:00","updated_at":"2026-06-05T16:56:30.022587+00:00","problems":[{"fix":"Create a subclass: class MyTable extends tablebase { constructor(db) { super(db, 'tablename'); } }","cause":"Trying to instantiate tablebase directly instead of subclassing it.","error":"TypeError: tablebase is not a constructor"},{"fix":"Verify column names: they must match exactly the keys used in regColumn.","cause":"Column name used in condition does not match the registered column name.","error":"Error: DB_SqlException: Unknown column '...' in 'where clause'"},{"fix":"Check host, port, and ensure MySQL/MSSQL service is started.","cause":"Database server is not running or connection parameters are incorrect.","error":"Error: DB_ConneException: connect ECONNREFUSED"},{"fix":"Ensure constructor calls super(db, tablename) and that db is a valid database instance.","cause":"tablebase instance not properly initialized; or using condition() before calling super().","error":"TypeError: Cannot read property 'condition' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/brainpoint/febs-db#readme","github":"ssh://git@github.com/brainpoint/febs-db","docs":null,"changelog":null,"pypi":null,"npm":"febs-db","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}