Registry / database / mikro-orm-arp

mikro-orm-arp

JSON →
library1.0.6jsnpmunverified

Active Record(-ish) Pattern for Mikro-ORM (v1.0.6). Adds repository methods (findOne, create, persist, flush, getRepo) directly as static methods on entities, eliminating the need to manually retrieve the entity manager or repository. Designed for @mikro-orm/core ^4.0.0-rc.4. Alternative to Data Mapper pattern; opinionated and lightweight. Low release cadence (no recent updates). Ships TypeScript declarations.

npm install mikro-orm-arp
INSTALL
IMPORT
SIG · MIKRO-ORM-ARP
M
mikro-orm-arp
databasejavascriptv1.0.6
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.

BaseEntity
import { BaseEntity } from 'mikro-orm-arp'
import { BaseEntity } from '@mikro-orm/core'
BaseEntity is provided by this package, not Mikro-ORM core.
register
import { register } from 'mikro-orm-arp'
const register = require('mikro-orm-arp').register
ESM only; require is supported but tree-shaking may fail.
default (all)
import * as Arp from 'mikro-orm-arp'
import Arp from 'mikro-orm-arp'
No default export; must use namespace or named imports.
Entity type exports
import type { Entity } from '@mikro-orm/core'
import { Entity } from 'mikro-orm-arp'
Decorators like @Entity come from @mikro-orm/core, not this package.

Shows how to define an entity extending BaseEntity, initialize MikroORM, register the active record pattern, and use static methods like findOneOrFail, create, persist, flush, and getRepo.

import { MikroORM, Entity, Property } from '@mikro-orm/core'; import { register, BaseEntity } from 'mikro-orm-arp'; @Entity() export class Book extends BaseEntity { @Property() name: string = ''; } MikroORM.init({ entities: [Book, BaseEntity], dbName: 'test', type: 'sqlite', }).then(async (orm) => { register(orm); const book = await Book.findOneOrFail({ name: 'Journey to the center of the earth' }); const newBook = Book.create({ name: 'New Book' }); Book.persist(newBook); await Book.flush; const bookRepo = Book.getRepo(); });
Debug
Known issues
gotcharegister() must be called after MikroORM.init() and before using static methods.
fix
Call register(orm) inside the .then() callback or await init.
affects: >=0.0.0
breakingMikro-ORM v5 dropped support for @mikro-orm/core v4 APIs; this package is tied to v4 rc.
fix
Use @mikro-orm/core@^4.0.0-rc.4; upgrade cannot be done without package update.
affects: >=1.0.0
deprecatedThe package is no longer actively maintained; last release 2020-10-14.
fix
Consider using Mikro-ORM's native entity manager or custom repositories.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'mikro-orm-arp' or its corresponding type declarations.
Package not installed or TypeScript not resolving types correctly.
fix
Run npm install mikro-orm-arp @mikro-orm/core and ensure tsconfig.json includes "moduleResolution": "node".
TypeError: BaseEntity.findOneOrFail is not a function
register() not called before using static methods.
fix
Call register(orm) immediately after MikroORM.init().
Argument of type 'typeof Book' is not assignable to parameter of type 'EntityClass<unknown>'.
Register expects a MikroORM instance, not a string or entity class.
fix
Ensure register(orm) receives the full orm object from MikroORM.init().
Upgrade
Version history
1.0.6latest on npm
Audit
Dependencies
@mikro-orm/corerequiredPeer dependency; core MikroORM functionality required.
Agent activity
4 hits · last 30 days
node
4
Resources
mikro-orm-arp — npm install mikro-orm-arp · libregistry