The UML view — models as classes with their attributes and methods, for readers who think in objects rather than tables.The code#
import { ClassDiagram } from 'ts-prorm-orm';
const svg = new ClassDiagram({
title: 'Model classes',
classes: [
{ name: 'User',
attributes: ['id: number', 'email: string', 'name: string'],
methods: ['getPosts()', 'createPost()'] },
{ name: 'Post',
attributes: ['id: number', 'title: string', 'authorId: number'],
methods: ['getAuthor()'] },
],
}).generate();
What it produces#
Generated by running the snippet above — this is the generator's real output,
rebuilt by scripts/build-diagram-examples.mjs, not a picture of it.The association mixins prorm generates (getPosts, createPost, …) are worth listing as methods — they are the part of the model that is easy to forget exists.Saving it#
generate() returns the SVG as a string; save(path) writes it straight to
disk.diagram.save('docs/schema.svg');
Models — the definitions these are drawn from Modified at 2026-10-04 00:40:16