generate() on, returning the SVG as a string.scripts/build-diagram-examples.mjs, so an example cannot drift from what theimport { ERDiagram } from 'ts-prorm-orm';
const svg = new ERDiagram({ title: 'Blog', models: [User, Post, Tag] }).generate();
// or write it straight to disk:
new ERDiagram({ models: [User, Post, Tag] }).save('docs/schema.svg');DiagramType enum instead of importing its class:saveDiagram(DiagramType.ER, prormToER(prorm, { title: 'Schema' }), './schema.svg');theme and color options| Diagram | What it shows |
|---|---|
| ER diagram | Every model and the foreign keys between them |
| Model diagram | One table in detail: columns, types, keys |
| Crow’s foot | Cardinality — which side is one, which is many |
| Chen diagram | ER in Chen notation: diamonds and ovals |
| Schema documentation | A table as a data dictionary |
| Index diagram | Which indexes cover which columns |
| Migration diagram | What a migration does to a table |
| Diagram | What it shows |
|---|---|
| Sequence diagram | The call order during a write |
| State diagram | The states an instance moves through |
| Flow diagram | A read, from finder to instances |
| Diagram | What it shows |
|---|---|
| Tree diagram | A nested include, drawn as a tree |
| Dependency diagram | Create order, and its reverse for drops |
| Package diagram | How the ORM source is organised |
| Class diagram | Models as UML classes |
| Diagram | What it shows |
|---|---|
| Gantt diagram | A migration rollout over time |
ERDiagram and ModelDiagram take the same option objects you pass todefine(), so you can draw the schema you already have rather thanconst svg = new ERDiagram({
title: 'Production schema',
models: [UserOptions, PostOptions, TagOptions],
}).generate();