Licence
MIT
Version
3.0.0
Deps
0
Vulns
0
Weekly
0
fib-orm
ORM for fibjs — a unified ORM package supporting SQLite, MySQL, PostgreSQL, KingbaseES, Microsoft SQL Server and DM (达梦).
Install
npm install fib-orm
Quick Start
const ORM = require('fib-orm');
const db = ORM.connectSync('sqlite:test.db');
const User = db.define('user', {
name: String,
age: Number
});
db.syncSync();
User.createSync({ name: 'Alice', age: 30 });
const users = User.findSync();
console.log(users);
db.closeSync();
Run and check
fibjs executes the TypeScript sources directly, so there is no compiler or
lib/ build step. The runtime entry index.js is a CommonJS bridge over
src/orm/index.ts, which keeps require('fib-orm') working; index.d.ts adds
the default-export typing for import orm from 'fib-orm'.
# Type/syntax check (uses tsconfig.json, no emit)
npm run check
# CommonJS bridge: package entry, CJS/ESM interop, dynamic import()
npm run test:bridge
# ...and its declaration file
npm run check:bridge
# Use the library
fibjs -e "const ORM = require('fib-orm'); const db = ORM.connectSync('sqlite:test.db')"
Test
npm test runs the full integration suite and reads test/config.js (or
test/config.ci.js when CI is set). npm run test:smoke runs the compact
cross-driver smoke suite against one URI:
# SQLite
ORM_PROTOCOL=sqlite ORM_URI=sqlite:test.db npm run test:smoke
# MySQL
ORM_PROTOCOL=mysql ORM_URI=mysql://root:root_test@127.0.0.1:3306/test npm run test:smoke
# PostgreSQL
ORM_PROTOCOL=psql ORM_URI=psql://user:password@127.0.0.1:5432/test npm run test:smoke
# KingbaseES (KODBC)
ORM_PROTOCOL=kingbase ORM_URI='kingbase://user:password@127.0.0.1:54321/test?Driver=/path/to/kdbodbcw.so' npm run test:smoke
# Microsoft SQL Server
ORM_PROTOCOL=mssql ORM_URI='mssql://sa:password@127.0.0.1:1433/test' npm run test:smoke
# DM (达梦)
ORM_PROTOCOL=dm ORM_URI='dm://SYSDBA:password@127.0.0.1:5236/test' npm run test:smoke
For CI, every database can run the self-contained smoke suite:
ORM_PROTOCOL=mssql \
ORM_URI='mssql://sa:password@localhost:1433/test' \
fibjs test/integration/db-smoke.js
License
MIT