Registry / database / fluent-orm

fluent-orm

JSON →
library1.8.7jsnpmunverified

A JavaScript ORM inspired by Laravel's Eloquent, providing a fluent query builder for MySQL and PostgreSQL. Currently at version 1.8.7, it supports basic CRUD operations, relationships (hasMany), eager loading, and transactions. The library is experimental and may change structure significantly. It offers both ESM and CJS modules with built-in TypeScript declarations. Differentiators include a Laravel-like syntax, environment-based configuration, and a driver-based architecture supporting multiple databases.

npm install fluent-orm
INSTALL
IMPORT
SIG · FLUENT-ORM
F
fluent-orm
databasejavascriptv1.8.7
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.

Model
import { Model } from 'fluent-orm'
const Model = require('fluent-orm').Model
Both ESM and CJS imports work.
configurator
import { configurator } from 'fluent-orm'
import configurator from 'fluent-orm'
configurator is a named export, not default.
connection types
import type { ConnectionConfig } from 'fluent-orm'
import { ConnectionConfig } from 'fluent-orm'
Type imports require 'type' keyword for isolatedModules.

Shows full setup with PostgreSQL driver, model definition with hasMany relationship, and a basic query execution.

import { Model, configurator } from 'fluent-orm'; import pgDriver from 'fluent-pg'; configurator.use(pgDriver.configure); configurator.configure({ default: 'pgsql', connections: { pgsql: { driver: 'pgsql', host: process.env.DB_HOST ?? 'localhost', port: process.env.DB_PORT ?? '5432', database: process.env.DB_DATABASE ?? 'test', user: process.env.DB_USERNAME ?? 'postgres', password: process.env.DB_PASSWORD ?? '' } } }); class Person extends Model { emails() { return this.hasMany(Email, 'person_id', 'id'); } } Person.query().where('age', '>', 18).get().then(console.log);
Debug
Known issues
gotchaCalling configurator.use() with a non-existent driver will throw an error without clear message.
fix
Ensure driver packages are installed and correctly passed to configurator.use().
affects: >=1.0
deprecatedThe .env file configuration method using DB_CONNECTION, DB_HOST, etc. is deprecated. Use programmatic configurator.configure() instead.
fix
Switch to configurator.configure() for all connection settings.
affects: >=1.5
gotchaModel.create() returns the created element with a generated id, but Model.insert() does not return inserted IDs.
fix
Use Model.create() for single insert with id return, or Model.insert() for bulk inserts without ids.
affects: >=1.0
gotchaTransaction callback does not automatically handle errors; you must manually call commit() or rollback(). In async/await pattern, missing error handling can leave transactions hanging.
fix
Always wrap transaction logic in try/catch and ensure rollback() is called on error.
affects: >=1.0
Errors
Common errors & fixes
TypeError: configurator.use is not a function
Importing configurator as default instead of named export.
fix
Use import { configurator } from 'fluent-orm'
Error: Driver not found for database type 'mysql'
Missing or misconfigured driver package (e.g., fluent-mysql not installed).
fix
Install the appropriate driver: npm install fluent-mysql
Cannot read property 'query' of undefined
Model class not exported correctly or not extending Model.
fix
Ensure class extends Model and is exported: export default class Person extends Model
Upgrade
Version history
1.8.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
fluent-orm — npm install fluent-orm · libregistry