Registry / database / yandjin-mikro-orm

yandjin-mikro-orm

JSON →
library6.1.4-rc-sti-changes-1jsnpmunverified

TypeScript ORM for Node.js based on Data Mapper, Unit of Work, and Identity Map patterns. Version 6.1.4-rc-sti-changes-1 supports MongoDB, MySQL, MariaDB, PostgreSQL, and SQLite databases. Heavily inspired by Doctrine and Hibernate, it provides implicit transactions via flush(), change-set based persistence, and a rich set of features like migrations, embedded entities, and query building. It ships with TypeScript definitions and requires Node >= 18.12.0. Key differentiators: full TypeScript support, no decorator metadata reflection needed, and a clean, opinionated API.

npm install yandjin-mikro-orm
INSTALL
IMPORT
SIG · YANDJIN-MIKRO-ORM
Y
yandjin-mikro-orm
databasejavascriptv6.1.4-rc-sti-changes-1
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 '@mikro-orm/core'
import { Entity } from 'mikro-orm'
All imports are from '@mikro-orm/core' (or sub-packages like '@mikro-orm/sqlite'), not 'mikro-orm'.
EntityManager
import { EntityManager } from '@mikro-orm/core'
const { EntityManager } = require('@mikro-orm/core')
ESM-only since v6; require() will fail. Always use import.
MikroORM
import { MikroORM } from '@mikro-orm/core'
import MikroORM from '@mikro-orm/core'
MikroORM is a named export, not a default export.
defineConfig
import { defineConfig } from '@mikro-orm/core'
Available since v5; preferred way to configure MikroORM.

Shows minimal setup: define an entity, init ORM with SQLite in-memory, persist and find entities.

import { MikroORM, Entity, PrimaryKey, Property, defineConfig } from '@mikro-orm/sqlite'; @Entity() class User { @PrimaryKey() id!: number; @Property() name!: string; constructor(name: string) { this.name = name; } } const orm = await MikroORM.init( defineConfig({ entities: [User], dbName: ':memory:', debug: true, }), ); const em = orm.em; const user = new User('John Doe'); em.persistAndFlush(user); const users = await em.find(User, {}); console.log('Users:', users); await orm.close();
Debug
Known issues
breakingSwitched to ESM-only in v6. require() will throw.
fix
Switch to ESM ("type": "module" in package.json) and use import syntax.
affects: >=6.0.0
deprecatedEntityManager.persist() is deprecated in favor of em.persistAndFlush() or em.persist() without flushing.
fix
Use em.persistAndFlush() for immediate flush, or em.persist() followed by em.flush().
affects: >=5.0.0
breakingMikroORM.init() no longer accepts a callback; use options object or defineConfig.
fix
Pass config object directly: MikroORM.init({ entities, dbName, ... }) or use defineConfig().
affects: >=5.0.0
gotchaDecorators require TypeScript's experimentalDecorators and emitDecoratorMetadata enabled.
fix
Set "experimentalDecorators": true and "emitDecoratorMetadata": true in tsconfig.json.
affects: >=4.0.0
gotcha@Property() is required for all non-primary key columns, even if using auto-mapping via reflect-metadata.
fix
Always include @Property() on every entity field you want to persist.
affects: >=4.0.0
Errors
Common errors & fixes
Entity 'User' not found. Did you forget to add it to the 'entities' array?
Entity class not registered in MikroORM configuration.
fix
Add the entity class to the 'entities' array in defineConfig({ entities: [User] }).
Cannot use import statement outside a module
Using ESM imports in a CommonJS environment (v6+).
fix
Add "type": "module" to package.json or rename file to .mjs.
Metadata for entity User was not found. Did you forget to use @Entity() decorator?
Missing decorator or experimentalDecorators not enabled.
fix
Add @Entity() decorator to class and enable experimentalDecorators in tsconfig.json.
Property 'id' does not have a type mapping. Did you forget to add @PrimaryKey()?
Missing @PrimaryKey() on the primary key property.
fix
Add @PrimaryKey() decorator to the id property.
Upgrade
Version history
6.1.4-rc-sti-changes-1latest on npm
Audit
Dependencies
@mikro-orm/corerequiredCore package for entities, EntityManager, and Unit of Work
@mikro-orm/sqliteoptionalSQLite driver (or alternative driver for your database)
Agent activity
20 hits · last 30 days
node
16
OpenAI (training)
1
Resources
yandjin-mikro-orm — npm install yandjin-mikro-orm · libregistry