Registry / database / undiorm

undiorm

JSON →
library0.0.101jsnpmunverified

Undiorm (currently at version 0.0.101) is a lightweight PostgreSQL ORM and query builder in active development. It provides a CLI for generating entities, migrations, and TypeScript types from PostgreSQL schemas. Currently supports basic ORM operations and advanced features like triggers and views. Not yet production-ready; frequent breaking changes expected. Aims to compete with TypeORM and MikroORM by offering a simpler, TypeScript-first API with native ESM support.

npm install undiorm
INSTALL
IMPORT
SIG · UNDIORM
U
undiorm
databasejavascriptv0.0.101
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.

default or named exports
import { createConnection } from 'undiorm'
const undiorm = require('undiorm')
Package is ESM-only; CommonJS require() will fail. Use named imports for main functions.
Entity decorators
import { Entity, PrimaryColumn, Column } from 'undiorm/decorators'
import { Entity } from 'undiorm'
Decorators are exported from a separate subpath 'undiorm/decorators' since v0.0.50.
Migration utilities
import { Migration } from 'undiorm/migration'
import { Migration } from 'undiorm'
Migration class is available under 'undiorm/migration' subpath.
CLI usage
npx undiorm migration:run
npm run undiorm migration:run
CLI is invoked via npx or package.json scripts, not as an npm run command directly.

Connects to PostgreSQL, defines an entity with decorators, and performs a basic insert operation using the repository pattern.

import { createConnection, Entity, PrimaryGeneratedColumn, Column } from 'undiorm'; @Entity() export class User { @PrimaryGeneratedColumn() id: number; @Column({ type: 'varchar', length: 100 }) name: string; } async function main() { const connection = await createConnection({ type: 'postgres', host: process.env.DB_HOST ?? 'localhost', port: parseInt(process.env.DB_PORT ?? '5432'), username: process.env.DB_USER ?? 'postgres', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', entities: [User], synchronize: true, }); const userRepository = connection.getRepository(User); const user = new User(); user.name = 'John Doe'; await userRepository.save(user); console.log('User saved with id:', user.id); } main().catch(console.error);
Debug
Known issues
breakingDecorator imports moved to a separate subpath 'undiorm/decorators' in v0.0.50.
fix
Update imports: import { Entity } from 'undiorm/decorators' instead of 'undiorm'.
affects: >=0.0.50
breakingPackage became ESM-only in v0.0.40; CommonJS require() throws Error.
fix
Use import syntax or enable ESM in your project (e.g., type: 'module' in package.json).
affects: >=0.0.40
gotchasynchronize: true in development may drop tables unexpectedly.
fix
Set synchronize: false in production; use migrations for schema changes.
affects: *
deprecatedThe 'createConnection' function is deprecated in favor of 'initialize' in v0.0.70+.
fix
Replace createConnection with initialize: const conn = await initialize({...});
affects: >=0.0.70
gotchaUninstalling undiorm does not clean up generated migration files or compiled entities.
fix
Manually remove 'migrations' and 'entities' directories if no longer needed.
affects: *
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported.
Attempted to use CommonJS require() on ESM-only package.
fix
Use import syntax in an ESM context (type: 'module' in package.json) or dynamic import().
TypeError: Cannot read properties of undefined (reading 'getRepository')
Connection not fully initialized before accessing repository.
fix
Ensure await on connection initialization before any repository operations.
SyntaxError: Unexpected token 'Entity'
Decorators used without enabling experimentalDecorators in tsconfig.json.
fix
Set 'experimentalDecorators': true and 'emitDecoratorMetadata': true in tsconfig.json.
Error: Cannot find module 'undiorm/decorators'
Using an older version of the package that did not have the decorators subpath.
fix
Update to version >=0.0.50 or import directly from 'undiorm' (old version).
Upgrade
Version history
0.0.101latest on npm
Audit
Dependencies
pgrequiredPostgreSQL client driver for database connectivity
typescriptoptionalType generation requires TypeScript compiler
Agent activity
26 hits · last 30 days
node
22
Meta
2
OpenAI (training)
1
Resources
undiorm — npm install undiorm · libregistry