콘텐츠로 이동

mikro-orm-markdown

MikroORM 엔티티에서 바로 만드는 Mermaid ERD와 Markdown 스키마 문서. DB 연결이 필요 없습니다.

npm install -D mikro-orm-markdown
/**
* Blog post authored by a registered user.
* @namespace Blog
*/
@Entity()
export class Post {
@PrimaryKey({ type: 'integer' })
id!: number;
/** Post title */
@Property({ type: 'string' })
title!: string;
@Property({ type: 'text', nullable: true })
body?: string;
@ManyToOne({ entity: () => Author })
author!: Author;
}
/**
* Blog post authored by a registered user.
* @namespace Blog
*/
export const PostSchema = new EntitySchema({
name: 'Post',
properties: {
id: { type: 'integer', primary: true },
/** Post title */
title: { type: 'string' },
body: { type: 'text', nullable: true },
author: { kind: 'm:1', entity: 'Author' },
},
});
/**
* Blog post authored by a registered user.
* @namespace Blog
*/
export const PostSchema = defineEntity({
name: 'Post',
properties: (p) => ({
id: p.integer().primary(),
/** Post title */
title: p.string(),
body: p.text().nullable(),
author: () => p.manyToOne(AuthorSchema),
}),
});

ERD.md

npx mikro-orm-markdown --config ./mikro-orm.config.ts --out ./ERD.md
ERD + 컬럼 표

Mermaid ER 다이어그램과 함께, 실제 DB 컬럼명, 키, nullable 여부, 설명, 인덱스, 제약 조건을 담은 엔티티별 표를 만듭니다.

JSDoc 기반

설명, 섹션(@namespace, @erd, @describe), 노출 여부(@hidden)를 엔티티 파일에 이미 있는 주석에서 가져옵니다.

MikroORM 개념 지원

Embeddable, Single Table Inheritance, @Formula, EntitySchema / defineEntity() 엔티티를 각각 독립된 개념으로 제대로 표현합니다.

DB 연결 불필요

MikroORM discovery로 엔티티 메타데이터를 읽습니다. SQLite, PostgreSQL, MySQL, MariaDB 드라이버에서 MikroORM 6과 7 모두 동작합니다.

  • 빠른 시작 — 스크립트를 추가하고 첫 ERD.md를 만듭니다.
  • CLI 옵션 — 모든 옵션과 기본값.
  • 예시 — 예제 엔티티로 실제 생성한 문서.