# fib-orm

> ORM for fibjs - unified package

Latest version **3.0.0** (published 2026-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install fib-orm
pnpm add fib-orm
yarn add fib-orm
bun add fib-orm
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2026-11-28 |
| First published | 2017-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fibjs |
| Maintainers | richardo2016, xicilion, d3j |
| Keywords | orm, database, fibjs, mysql, sqlite, postgres, kingbase, mssql, dm, redis |

## Links

- npm: https://www.npmjs.com/package/fib-orm
- Repository: https://github.com/fibjs/fib-orm
- Issues: https://github.com/fibjs/fib-orm/issues
- npm.io page: https://npm.io/package/fib-orm

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2026-11-28
- 2.1.0 — 2026-04-02
- 2.0.0 — 2026-02-11
- 1.4.2 — 2018-06-13
- 1.4.1 — 2018-06-09
- 1.4.0-dev — 2018-06-09
- 1.3.4 — 2018-05-11
- 1.3.2 — 2018-03-08
- 1.3.1 — 2017-11-14
- 1.3.0 — 2017-11-11
- 1.2.2 — 2017-10-09
- 1.2.0 — 2017-09-24
- 1.1.0 — 2017-07-08
- 1.0.4 — 2017-04-03
- 1.0.3 — 2017-03-21
- … 3 more at https://npm.io/package/fib-orm/versions

## README

## fib-orm

ORM for [fibjs](https://fibjs.org) — a unified ORM package supporting SQLite, MySQL, PostgreSQL, KingbaseES, Microsoft SQL Server and DM (达梦).

### Install

```bash
npm install fib-orm
```

### Quick Start

```js
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'`.

```bash
# 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:

```bash
# 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:

```bash
ORM_PROTOCOL=mssql \
ORM_URI='mssql://sa:password@localhost:1433/test' \
fibjs test/integration/db-smoke.js
```

### License

MIT

---
_Source: https://npm.io/package/fib-orm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
