Registry / database / mirror-orm

mirror-orm

JSON →
library1.0.7jsnpmunverified

Mirror ORM is a lightweight TypeScript ORM for PostgreSQL, SQLite, MySQL, and SQL Server, built on Stage 3 decorators (no experimentalDecorators required). Current stable version is 1.0.7. It features a fluent query builder, relations with batch loading (no N+1), transactions via AsyncLocalStorage, streaming, read replicas, optimistic and pessimistic locking, soft delete, lifecycle hooks, embedded value objects, single table inheritance, and JSON operators for PostgreSQL. Key differentiators include sub-100 ns/row hydration overhead, native ESM support, and zero-config TypeScript setup using standard decorators. Release cadence is active with frequent updates.

npm install mirror-orm
INSTALL
IMPORT
SIG · MIRROR-ORM
M
mirror-orm
databasejavascriptv1.0.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.

Connection
import { Connection } from 'mirror-orm'
const { Connection } = require('mirror-orm')
mirror-orm is ESM-only; requires Node >=20 and module setting in tsconfig.
Entity, Column, PrimaryColumn
import { Entity, Column, PrimaryColumn } from 'mirror-orm'
import { Entity } from 'mirror-orm/entity'
All decorators are exported from the main package index.
Repository
import type { Repository } from 'mirror-orm'
import { Repository } from 'mirror-orm/Repository'
Repository is an interface; use type import to avoid runtime overhead.

Defines a User entity, creates an in-memory SQLite database, syncs schema, and performs insert/find operations.

import { Connection, Entity, Column, PrimaryColumn, CreatedAt } from 'mirror-orm'; @Entity('users') class User { @PrimaryColumn({ strategy: 'identity' }) id!: number; @Column() name!: string; @Column({ nullable: true }) email!: string | null; @CreatedAt() createdAt!: Date; } const conn = await Connection.sqlite({ database: ':memory:' }); await conn.sync({ force: true }); const repo = conn.getRepository(User); const user = await repo.save(Object.assign(new User(), { name: 'Alice', email: 'alice@example.com' })); const found = await repo.findById(1); console.log(found.name); // Alice await conn.close();
Debug
Known issues
breakingRequires Node.js >=20.0.0 and pnpm >=10.0.0
fix
Update Node.js to v20+ and pnpm to v10+.
affects: >=1.0.0
breakingStage 3 decorators only; experimentalDecorators must be false in tsconfig
fix
Set "experimentalDecorators": false in tsconfig.json and ensure target is ES2022 or later.
affects: >=1.0.0
breakingESM-only package. CommonJS require() will fail.
fix
Use import syntax and set "type": "module" in package.json or use .mjs extension.
affects: >=1.0.0
deprecatedNo deprecated features currently reported.
gotchaRepository methods (e.g., findById) return undefined for none found, not null.
fix
Check for undefined explicitly: const user = await repo.findById(id); if (user === undefined) ...
affects: >=1.0.0
gotchaConnection.sync({ force: true }) drops and recreates tables. Use with caution in production.
fix
Use migrations or set force: false to only create missing tables.
affects: >=1.0.0
Errors
Common errors & fixes
Experimental decorators warning: The 'experimentalDecorators' option is required for decorators to work.
tsconfig.json has experimentalDecorators: true or is missing.
fix
Set "experimentalDecorators": false in tsconfig.json and update target to ES2022.
TypeError: Class constructor User cannot be invoked without 'new'
Using require() instead of import for ESM package.
fix
Change to import { User } from 'mirror-orm' and use new User().
Cannot find module 'pg' or 'better-sqlite3'
Database driver not installed.
fix
Install the appropriate driver: npm install pg (PostgreSQL), better-sqlite3 (SQLite), etc.
Error: No metadata for "User". Did you forget to add @Entity?
Entity class is missing @Entity decorator or not registered before use.
fix
Add @Entity('tablename') to the class and ensure it is imported before calling getRepository.
Upgrade
Version history
1.0.7latest on npm
Audit
Dependencies
better-sqlite3optionalRequired for SQLite support
mssqloptionalRequired for SQL Server support
mysql2optionalRequired for MySQL support
pgoptionalRequired for PostgreSQL support
Agent activity
5 hits · last 30 days
node
4
Resources
mirror-orm — npm install mirror-orm · libregistry