Registry / database / metal-orm

metal-orm

JSON →
library1.1.11jsnpmunverified

MetalORM is a TypeScript-first ORM and SQL query builder for Node.js (v20+) that supports gradual adoption from raw SQL building to full ORM with entities, Unit of Work, and decorators. Version 1.1.11 is currently stable, with active development and monthly releases. Key differentiators: zero `any` types in codebase, AST-driven architecture enabling multi-dialect support (MySQL, PostgreSQL, SQLite, SQL Server), and three abstraction levels (query builder, ORM runtime, decorator entities) that share the same foundation. It ships with TypeScript types and peer dependencies for popular database drivers.

npm install metal-orm
INSTALL
IMPORT
SIG · METAL-ORM
M
metal-orm
databasejavascriptv1.1.11
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.

defineTable
import { defineTable } from 'metal-orm'
const { defineTable } = require('metal-orm')
ESM-only package; require is not supported.
col
import { col } from 'metal-orm'
import { col } from 'metal-orm/col'
col is exported from the main entry, not a subpath.
selectFrom
import { selectFrom } from 'metal-orm'
import { selectFrom } from 'metal-orm/query'
selectFrom is exported from the main entry.

Defines a table with typed schema, builds a query, and compiles to SQL using MySQL dialect.

import { defineTable, col, selectFrom, MySqlDialect } from 'metal-orm'; const users = defineTable('users', { id: col.primaryKey(col.int()), name: col.varchar(255), }); const query = selectFrom(users).select('id', 'name').limit(10); const { sql, params } = query.compile(new MySqlDialect()); console.log(sql); // SELECT id, name FROM users LIMIT 10 console.log(params); // []
Debug
Known issues
breakingNode.js <20 is not supported. Engine requirement is >=20.0.0
fix
Upgrade Node.js to v20 or later.
affects: <1.0.0
deprecatedThe `@Entity` decorator does not support automatic table name resolution; you must provide an explicit name.
fix
Always pass table name to @Entity decorator.
affects: >=1.0.0
gotchaPeer dependencies for database drivers are optional but compilation will fail if a dialect is used without the corresponding driver installed.
fix
Install the required driver: e.g., npm install pg for PostgreSQL.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'metal-orm'
The package is ESM-only and not compatible with CommonJS require()
fix
Use import statement: import { defineTable } from 'metal-orm'; or set 'type': 'module' in package.json.
TypeError: metal_orm.col is undefined
Incorrect import path: 'metal-orm/col' does not exist
fix
Import col from 'metal-orm' directly.
Error: No dialect provided
Query compile was called without passing a dialect instance
fix
Call compile(new MySqlDialect()) or appropriate dialect.
Upgrade
Version history
1.1.11latest on npm
Audit
Dependencies
better-sqlite3optionalRequired for SQLite dialect when using better-sqlite3 driver
ioredisoptionalRequired for Redis caching adapter
keyvoptionalRequired for Keyv caching adapter
mysql2optionalRequired for MySQL dialect
pgoptionalRequired for PostgreSQL dialect
sqlite3optionalRequired for SQLite dialect when using sqlite3 driver
tediousoptionalRequired for SQL Server dialect
Agent activity
2 hits · last 30 days
node
2
Resources
metal-orm — npm install metal-orm · libregistry