Registry / database / egg-orm-ts

egg-orm-ts

JSON →
library0.2.12jsnpmunverified

Simple ORM plugin for Egg.js with TypeORM integration, version 0.2.12. Provides BaseController, BaseService, and utility classes to simplify CRUD operations within Egg applications. Ships TypeScript types and supports Node >=8.0.0. Differentiator: reduces boilerplate by offering pre-built controller/service patterns with automatic parameter validation via Joi and unified response handling. Note: project appears low-activity with sparse documentation and limited downloads; evaluate stability before production use.

npm install egg-orm-ts
INSTALL
IMPORT
SIG · EGG-ORM-TS
E
egg-orm-ts
databasejavascriptv0.2.12
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.

BaseController
import { BaseController } from 'egg-orm-ts'
const BaseController = require('egg-orm-ts').BaseController
ESM import recommended; CommonJS require also works but may break with tree-shaking
BaseService
import { BaseService } from 'egg-orm-ts'
const BaseService = require('egg-orm-ts').BaseService
BaseService is a generic class; use with entity type e.g., BaseService<Demo>
callService
import { callService } from 'egg-orm-ts'
const callService = require('egg-orm-ts').callService
callService is a helper function used within BaseController methods

Demonstrates complete setup: plugin enable, database config, entity definition, service with BaseService, and controller with BaseController using callService and Joi validation.

// config/plugin.js exports.ormTs = { enable: true, package: 'egg-orm-ts' }; // config/config.default.ts exports.typeorm = { type: 'mysql', host: 'localhost', port: 3306, username: 'root', password: process.env.DB_PASSWORD ?? '', database: 'test', synchronize: true, entities: ['app/entity/**/*.ts'], }; // app/entity/demo.ts import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; @Entity() export class Demo { @PrimaryGeneratedColumn() id: number; @Column() name: string; } // app/service/demo.ts import { BaseService } from 'egg-orm-ts'; import { Demo } from '../entity/demo'; export default class DemoService extends BaseService<Demo> { async demo(params) { return this.getList(params); } } // app/controller/demo.ts import { BaseController } from 'egg-orm-ts'; import Joi from 'joi'; export default class DemoController extends BaseController { async demo() { const { ctx, callService } = this; const result = await callService(ctx.request.body, Joi.object({ name: Joi.string().required() }).required()); ctx.body = this.success(result); } }
Debug
Known issues
breakingv0.1.0 changed import paths from 'egg-orm-ts/dist/BaseController' to 'egg-orm-ts'
fix
Update imports to: import { BaseController } from 'egg-orm-ts'
affects: <0.1.0
deprecatedcallService without Joi schema will default to no validation - may lead to unexpected behavior
fix
Always provide a Joi schema as second argument, or null explicitly
affects: >=0.1.0
gotchaBaseService.getList() returns all entities without pagination; may cause memory issues
fix
Use getPage() for paginated results or apply where/limit conditions
affects: >=0.0.1
gotchaTypeORM synchronize: true in production can drop tables
fix
Set synchronize: false in production and use migrations
affects: >=0.0.1
deprecatedProject uses deprecated egg plugin format; may not work with Egg 3.x
fix
Check compatibility with your Egg version or migrate to egg-ts-orm alternative
affects: >=0.0.1
gotchaJoi is optional but callService will throw if schema is not provided and body is invalid
fix
Install joi as dependency and pass schema or null
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: Cannot read property 'prototype' of undefined
Importing BaseService/BaseController using CommonJS in TypeScript without default export
fix
Use import { BaseService } from 'egg-orm-ts' instead of require('egg-orm-ts').BaseService
Cannot find module 'egg-orm-ts'
Package not installed or missing in dependencies
fix
Run npm install egg-orm-ts --save
Entity metadata for Demo#id was not found
Entity file not loaded; entity path misconfigured or missing @Entity decorator
fix
Ensure entity file exists in app/entity and path is correct in config.typeorm.entities
Upgrade
Version history
0.2.12latest on npm
Audit
Dependencies
eggrequiredPlugin designed for Egg.js framework; requires egg as peer dependency
typeormrequiredCore ORM functionality provided by TypeORM
joioptionalUsed for parameter validation in controllers
Agent activity
8 hits · last 30 days
node
6
Resources
egg-orm-ts — npm install egg-orm-ts · libregistry