Registry / database / myorm_pg

myorm_pg

JSON →
library10.1.0jsnpmunverified

MyORM PG is a TypeScript-written ORM for PostgreSQL, providing a type-safe query builder and active-record like patterns. Version 10.1.0 is the latest stable release, with monthly updates. It differentiates itself with full TypeScript support, decorator-based entity definitions, and automatic migration generation. Requires reflect-metadata for runtime reflection.

npm install myorm_pg
INSTALL
IMPORT
SIG · MYORM_PG
M
myorm_pg
databasejavascriptv10.1.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.

Entity
import { Entity } from 'myorm_pg'
const { Entity } = require('myorm_pg')
ESM-only since v10; CommonJS require will fail.
PrimaryGeneratedColumn
import { PrimaryGeneratedColumn } from 'myorm_pg'
import { PrimaryGeneratedColumn } from 'myorm_pg/decorators'
All decorators are re-exported from the main module; no need for subpath imports.
createConnection
import { createConnection } from 'myorm_pg'
import { createConnection } from 'myorm_pg/connection'
createConnection is a top-level export since v8.
getRepository
import { getRepository } from 'myorm_pg'
Type-safe repository factory; returns a typed Repository<T>.

Shows how to define an entity with decorators, create a connection, and perform insert/find operations.

import 'reflect-metadata'; import { Entity, PrimaryGeneratedColumn, Column, createConnection, getRepository } from 'myorm_pg'; @Entity('users') class User { @PrimaryGeneratedColumn() id!: number; @Column() name!: string; } async function main() { await createConnection({ host: process.env.DB_HOST ?? 'localhost', port: Number(process.env.DB_PORT) || 5432, username: process.env.DB_USER ?? 'postgres', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', entities: [User] }); const userRepo = getRepository(User); const newUser = userRepo.create({ name: 'Alice' }); await userRepo.save(newUser); const users = await userRepo.find(); console.log(users); } main().catch(console.error);
Debug
Known issues
breakingStarting from v10, ESM-only: CommonJS require() will throw if used directly.
fix
Switch to ESM imports or use dynamic import().
affects: >=10.0.0
deprecatedThe 'ormconfig.json' file is deprecated; use programmatic connection options instead.
fix
Pass connection configuration directly to createConnection().
affects: >=9.0.0
gotchareflect-metadata must be imported at the entry point before using any decorators, otherwise decorators will silently fail.
fix
Add import 'reflect-metadata' as the first line in your main file.
affects: >=1.0.0
breakingIn v8, the repository API changed: save() returns the entity with generated fields, previously returned raw result.
fix
Update code to use returned entity directly; old patterns expecting raw result may break.
affects: >=8.0.0
gotchaColumn type mapping: 'string' maps to PostgreSQL 'text', not 'varchar'.
fix
Use @Column({ type: 'varchar' }) if you need varchar explicitly.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'reflect-metadata'
reflect-metadata is not installed despite being listed as peer dependency.
fix
Run 'npm install reflect-metadata' or add it to your package.json.
EntityMetadataNotFoundError: No metadata for "User" was found.
The entity class is not registered in the connection options' 'entities' array or decorators are not applied.
fix
Ensure the entity is added to the entities array in createConnection and that reflect-metadata is imported.
DataError: invalid input syntax for type integer
A column mapped as number receives a non-numeric string value.
fix
Validate input types before assigning; use TypeScript to enforce types at compile time.
Upgrade
Version history
10.1.0latest on npm
Audit
Dependencies
reflect-metadatarequiredRequired for decorator-based entity definitions and runtime type reflection
Agent activity
7 hits · last 30 days
node
6
Resources
myorm_pg — npm install myorm_pg · libregistry