{"id":44157,"library":"yandjin-mikro-orm","title":"MikroORM","description":"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.","status":"active","version":"6.1.4-rc-sti-changes-1","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/mikro-orm/mikro-orm","tags":["javascript","orm","mongo","mongodb","mysql","mariadb","postgresql","sqlite","sqlite3","typescript"],"install":[{"cmd":"npm install yandjin-mikro-orm","lang":"bash","label":"npm"},{"cmd":"yarn add yandjin-mikro-orm","lang":"bash","label":"yarn"},{"cmd":"pnpm add yandjin-mikro-orm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core package for entities, EntityManager, and Unit of Work","package":"@mikro-orm/core","optional":false},{"reason":"SQLite driver (or alternative driver for your database)","package":"@mikro-orm/sqlite","optional":true}],"imports":[{"note":"All imports are from '@mikro-orm/core' (or sub-packages like '@mikro-orm/sqlite'), not 'mikro-orm'.","wrong":"import { Entity } from 'mikro-orm'","symbol":"Entity","correct":"import { Entity } from '@mikro-orm/core'"},{"note":"ESM-only since v6; require() will fail. Always use import.","wrong":"const { EntityManager } = require('@mikro-orm/core')","symbol":"EntityManager","correct":"import { EntityManager } from '@mikro-orm/core'"},{"note":"MikroORM is a named export, not a default export.","wrong":"import MikroORM from '@mikro-orm/core'","symbol":"MikroORM","correct":"import { MikroORM } from '@mikro-orm/core'"},{"note":"Available since v5; preferred way to configure MikroORM.","wrong":"","symbol":"defineConfig","correct":"import { defineConfig } from '@mikro-orm/core'"}],"quickstart":{"code":"import { MikroORM, Entity, PrimaryKey, Property, defineConfig } from '@mikro-orm/sqlite';\n\n@Entity()\nclass User {\n  @PrimaryKey()\n  id!: number;\n\n  @Property()\n  name!: string;\n\n  constructor(name: string) {\n    this.name = name;\n  }\n}\n\nconst orm = await MikroORM.init(\n  defineConfig({\n    entities: [User],\n    dbName: ':memory:',\n    debug: true,\n  }),\n);\n\nconst em = orm.em;\nconst user = new User('John Doe');\nem.persistAndFlush(user);\nconst users = await em.find(User, {});\nconsole.log('Users:', users);\nawait orm.close();","lang":"typescript","description":"Shows minimal setup: define an entity, init ORM with SQLite in-memory, persist and find entities."},"warnings":[{"fix":"Switch to ESM (\"type\": \"module\" in package.json) and use import syntax.","message":"Switched to ESM-only in v6. require() will throw.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Use em.persistAndFlush() for immediate flush, or em.persist() followed by em.flush().","message":"EntityManager.persist() is deprecated in favor of em.persistAndFlush() or em.persist() without flushing.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Pass config object directly: MikroORM.init({ entities, dbName, ... }) or use defineConfig().","message":"MikroORM.init() no longer accepts a callback; use options object or defineConfig.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Set \"experimentalDecorators\": true and \"emitDecoratorMetadata\": true in tsconfig.json.","message":"Decorators require TypeScript's experimentalDecorators and emitDecoratorMetadata enabled.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Always include @Property() on every entity field you want to persist.","message":"@Property() is required for all non-primary key columns, even if using auto-mapping via reflect-metadata.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"search_vec":"'1':23 '18.12.0':70 '6.1.4':18 'api':85 'base':6,47 'build':61 'chang':22,45 'change-set':44 'clean':83 'data':8 'databas':31 'decor':77 'definit':66 'differenti':72 'doctrin':35 'embed':57 'entiti':58 'featur':54 'flush':43 'full':73 'heavili':32 'hibern':37 'ident':14 'implicit':40 'inspir':33 'javascript':86 'key':71 'like':55 'map':15 'mapper':9 'mariadb':27,91 'metadata':78 'migrat':56 'mikroorm':1 'mongo':88 'mongodb':25,89 'mysql':26,90 'need':80 'node':69 'node.js':5 'opinion':84 'orm':3,87 'pattern':16 'persist':48 'postgresql':28,92 'provid':39 'queri':60 'rc':20 'rc-sti-chang':19 'reflect':79 'requir':68 'rich':51 'set':46,52 'ship':63 'sqlite':30,93 'sqlite3':94 'sti':21 'support':24,75 'transact':41 'typescript':2,65,74,95 'unit':10 'version':17 'via':42 'work':12","created_at":"2026-06-05T17:03:15.004855+00:00","updated_at":"2026-06-05T17:03:15.004855+00:00","problems":[{"fix":"Add the entity class to the 'entities' array in defineConfig({ entities: [User] }).","cause":"Entity class not registered in MikroORM configuration.","error":"Entity 'User' not found. Did you forget to add it to the 'entities' array?"},{"fix":"Add \"type\": \"module\" to package.json or rename file to .mjs.","cause":"Using ESM imports in a CommonJS environment (v6+).","error":"Cannot use import statement outside a module"},{"fix":"Add @Entity() decorator to class and enable experimentalDecorators in tsconfig.json.","cause":"Missing decorator or experimentalDecorators not enabled.","error":"Metadata for entity User was not found. Did you forget to use @Entity() decorator?"},{"fix":"Add @PrimaryKey() decorator to the id property.","cause":"Missing @PrimaryKey() on the primary key property.","error":"Property 'id' does not have a type mapping. Did you forget to add @PrimaryKey()?"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://mikro-orm.io","github":"ssh://git@github.com/mikro-orm/mikro-orm","docs":null,"changelog":null,"pypi":null,"npm":"yandjin-mikro-orm","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}