Which indexes cover which columns — the picture to look at before adding another one.The code#
import { IndexDiagram } from 'ts-prorm-orm';
const svg = new IndexDiagram({
title: 'posts indexes',
table: 'posts',
columns: [
{ name: 'id' }, { name: 'title' }, { name: 'authorId' }, { name: 'createdAt' },
],
indexes: [
{ name: 'posts_pkey', columns: ['id'], unique: true },
{ name: 'posts_author_created', columns: ['authorId', 'createdAt'] },
{ name: 'posts_title_idx', columns: ['title'] },
],
}).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.A composite index reads left to right: posts_author_created serves a filter on authorId, or on authorId and createdAt — but not on createdAt alone.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