mikro-orm-markdown
Mermaid ERD and Markdown schema docs, generated straight from your MikroORM entities. No database connection required.
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;}/** * Registered user who writes posts. * @namespace Blog */@Entity()export class Author { @PrimaryKey({ type: 'integer' }) id!: number;
@Property({ type: 'string' }) name!: string;
@Property({ type: 'string', unique: true }) email!: string;}/** * 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' }, },});/** * Registered user who writes posts. * @namespace Blog */export const AuthorSchema = new EntitySchema({ name: 'Author', properties: { id: { type: 'integer', primary: true }, name: { type: 'string' }, email: { type: 'string', unique: true }, },});/** * 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), }),});/** * Registered user who writes posts. * @namespace Blog */export const AuthorSchema = defineEntity({ name: 'Author', properties: (p) => ({ id: p.integer().primary(), name: p.string(), email: p.string().unique(), }),});ERD.md
npx mikro-orm-markdown --config ./mikro-orm.config.ts --out ./ERD.mdWhat you get
Section titled “What you get”- An ERD and column tables
A Mermaid ER diagram plus per-entity tables with real DB column names, keys, nullability, descriptions, indexes, and constraints.
- Driven by JSDoc
Descriptions, sections (
@namespace,@erd,@describe), and visibility (@hidden) come from the comments already in your entity files.- MikroORM-aware
Embeddables, single table inheritance,
@Formula, andEntitySchema/defineEntity()entities render as first-class concepts.- No database needed
Reads entity metadata through MikroORM discovery. Works with MikroORM 6 and 7 on SQLite, PostgreSQL, MySQL, and MariaDB drivers.
Where to go next
Section titled “Where to go next”- Quick start — add a script and generate your first
ERD.md. - CLI options — every flag, with defaults.
- Examples — real documents generated from sample entities.