Registry / database / kobp-mikroorm

kobp-mikroorm

JSON →
library3.0.5jsnpmunverified

ORM integration and CRUD controllers for Kobp framework, providing MikroORM entity management and automatic RESTful CRUD route generation. Current stable version is 3.0.5, typically released alongside Kobp core. Key differentiators: seamless integration with Kobp's decorator-based routing, automatic CRUD middleware generation from MikroORM entities, and TypeScript-first design. Requires @mikro-orm/core v6, @mikro-orm/knex v6, lodash, and kobp v3. Designed for Node.js backends using Koa and MikroORM.

npm install kobp-mikroorm
INSTALL
IMPORT
SIG · KOBP-MIKROORM
K
kobp-mikroorm
databasejavascriptv3.0.5
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.

CrudService
import { CrudService } from 'kobp-mikroorm'
const CrudService = require('kobp-mikroorm')
ESM-only since v3; CommonJS require is not supported.
withCrud
import { withCrud } from 'kobp-mikroorm'
Decorator or higher-order function to add CRUD routes to a controller.
MikroCrudController
import { MikroCrudController } from 'kobp-mikroorm'
import { MikroCrudController } from 'kobp'
MikroCrudController is exported from kobp-mikroorm, not from kobp core.

Defines a MikroORM entity and a basic CRUD controller using MikroCrudController, demonstrating entity definition and CRUD route setup.

import { Entity, PrimaryKey, Property } from '@mikro-orm/core'; import { MikroCrudController } from 'kobp-mikroorm'; @Entity() export class User { @PrimaryKey() id!: number; @Property() name!: string; } import { Route, BaseRoutedController, KobpServiceContext } from 'kobp'; import { RequestContext } from '@mikro-orm/core'; class UserController extends MikroCrudController<User>(User) { @Route('get', '/') async list(ctx: KobpServiceContext) { return RequestContext.getEntityManager().find(User, {}); } }
Debug
Known issues
breakingMikroCrudController signature changed in v3 - now expects entity class instead of string name
fix
Pass entity class constructor instead of string: MikroCrudController(User) vs MikroCrudController('User')
affects: >=3.0.0
deprecatedCrudService constructor no longer accepts entity name string; use entity class reference
fix
Use entity class: new CrudService(User) instead of new CrudService('User')
affects: >=3.0.0
breakingwithCrud decorator no longer automatically applies RequestContext middleware; must be manually added
fix
Wrap controller methods with RequestContext.create() or use @RequestContext() decorator from @mikro-orm/core
affects: >=3.0.0
gotchaThe package is ESM-only since v3. CJS projects must upgrade to ESM or use dynamic import().
fix
Convert project to ESM by adding 'type': 'module' to package.json, or use await import('kobp-mikroorm')
affects: >=3.0.0
Errors
Common errors & fixes
Error: Cannot find module 'kobp-mikroorm'
Package not installed or ESM/CJS mismatch in Node.js <14
fix
npm install kobp-mikroorm@latest and ensure Node.js >=14 with ESM support
TypeError: Class extends value undefined is not a constructor or null
MikroCrudController exported incorrectly due to circular dependency or incorrect entity class reference
fix
Check import path: import { MikroCrudController } from 'kobp-mikroorm' and ensure entity class is exported and imported before use
ValidationError: No database connection found after multiple retries
RequestContext middleware not applied; MikroORM identity map not configured
fix
Ensure RequestContext.create() is wrapping controller method calls or app.use() middleware is applied
Upgrade
Version history
3.0.5latest on npm
Audit
Dependencies
@mikro-orm/corerequiredCore ORM dependency for entity management and database operations
@mikro-orm/knexrequiredRequired for knex-based database driver support
lodashrequiredUtility functions for object manipulation and merge operations
kobprequiredCore Kobp framework providing base controller and routing infrastructure
Agent activity
2 hits · last 30 days
node
2
Resources
kobp-mikroorm — npm install kobp-mikroorm · libregistry