Registry / database / forge-orm

forge-orm

JSON →
library1.3.0jsnpmunverified

forge-orm is a multi-database ORM/wrapper (v1.3.0) that provides a Prisma-shaped query API for MongoDB, PostgreSQL, MySQL, and SQLite from a single codebase with no code generation and no query engine. You define models in plain TypeScript and the same queries run against any of the four databases by parsing the connection URL to select the correct driver. It ships TypeScript types, supports relations, transactions, aggregates, full-text search, soft delete, views, and raw SQL. Compared to alternatives like Prisma or Drizzle, forge-orm is significantly smaller (~5,000 lines of TypeScript), has no build step or generated client, and is MIT-licensed. However, it is a young library with a smaller ecosystem and no production track record. Peer dependencies include better-sqlite3, mongodb, mysql2, and pg; you only need to install the driver you require.

npm install forge-orm
INSTALL
IMPORT
SIG · FORGE-ORM
F
forge-orm
databasejavascriptv1.3.0
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.

createDb
import { createDb } from 'forge-orm'
import createDb from 'forge-orm'
createDb is a named export, not a default export.
f
import { f } from 'forge-orm'
const f = require('forge-orm').f
CommonJS require works but named exports are idiomatic for ESM.
model
import { model } from 'forge-orm'
model is a named export used to define schema models.
InferModel
import { InferModel } from 'forge-orm'
InferModel is a TypeScript type export for inferring the row type from a model definition.

Defines a User model, creates a database connection, inserts a record, and queries with a filter and limit.

import { createDb, f, model } from 'forge-orm'; const User = model('users', { id: f.id(), email: f.string().unique(), name: f.string(), }); const db = await createDb({ url: process.env.DATABASE_URL ?? 'postgresql://user:pass@localhost/db', schema: { user: User }, }); const alice = await db.user.create({ data: { email: 'alice@example.com', name: 'Alice' }, }); const users = await db.user.findMany({ where: { name: { contains: 'Ali' } }, take: 10, }); console.log(users);
Debug
Known issues
breakingforge-orm is young and may have breaking changes before v2.0.0.
fix
Pin to a specific version and test upgrades carefully.
affects: <2.0.0
gotchaPeer dependencies are not installed automatically; you must manually install the driver for your database.
fix
Run `npm install pg` (or mysql2, better-sqlite3, mongodb) alongside forge-orm.
affects: *
gotchaConnection URL must be a valid database connection string; forge-orm does not validate the URL until connection time.
fix
Ensure DATABASE_URL is set correctly for your chosen database (e.g., postgresql://, mysql://, sqlite://, mongodb://).
affects: *
deprecatedNo known deprecations yet.
affects: *
Errors
Common errors & fixes
Cannot find module 'pg' (or 'mysql2', etc.)
Missing peer dependency for the database driver.
fix
Install the required driver: npm install pg (replace with your driver).
TypeError: createDb is not a function
Incorrect import: createDb imported as default instead of named export.
fix
Use `import { createDb } from 'forge-orm'` instead of `import createDb from 'forge-orm'`.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
better-sqlite3optionalSQLite driver — required only if using SQLite
mongodboptionalMongoDB driver — required only if using MongoDB
mysql2optionalMySQL driver — required only if using MySQL
pgoptionalPostgreSQL driver — required only if using PostgreSQL
Agent activity
5 hits · last 30 days
node
4
Resources
forge-orm — npm install forge-orm · libregistry