Index diagram
Read this page in the documentation
Index diagram Which indexes cover which columns — the picture to look at before adding another one. The code 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. <div class="diagram-example"> <!-- Generated by ts-prorm-orm IndexDiagram --> <svg xmlns="http://www.w3.org/2000/svg" width="726" height="396" viewBox="0 0 726 396"><rect width="726" height="396" fill="#ffffff"/><rect x="28" y="28" width="670" height="60" fill="#f0f0f0" stroke="#000000" stroke-width="1"/><text x="46" y="55" font-family="ui-sans-serif, -apple-system, Segoe UI, Helvetica, Arial, sans-serif" font-size="20" font-weight="bold" fill="#000000">posts indexes</text><text x="46" y="75" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="11" fill="#666666">4 columns, 3 indexes</text><text x="682" y="61" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="12" font-weight="bold" fill="#000000" text-anchor="end">posts</text><text x="278" y="106" font-family="ui-sans-serif, -apple-system, Segoe UI, Helvetica, Arial, sans-serif" font-size="11" font-weight="bold" letter-spacing="1" fill="#666666">COLUMNS</text><rect x="278" y="114" width="96" height="46" fill="#ffffff" stroke="#000000" stroke-width="1"/><text x="326" y="134" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="13" font-weight="bold" fill="#000000" text-anchor="middle">id</text><rect x="386" y="114" width="96" height="46" fill="#ffffff" stroke="#000000" stroke-width="1"/><text x="434" y="134" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="13" font-weight="bold" fill="#000000" text-anchor="middle">title</text><rect x="494" y="114" width="96" height="46" fill="#ffffff" stroke="#000000" stroke-width="1"/><text x="542" y="134" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="13" font-weight="bold" fill="#000000" text-anchor="middle">authorId</text><rect x="602" y="114" width="96" height="46" fill="#ffffff" stroke="#000000" stroke-width="1"/><text x="650" y="134" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="13" font-weight="bold" fill="#000000" text-anchor="middle">createdAt</text><rect x="36" y="221" width="30" height="24" fill="#f0f0f0" stroke="#000000" stroke-width="1"/><text x="51" y="238" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="11" font-weight="bold" fill="#000000" text-anchor="middle">IX</text><text x="76" y="231" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="12" font-weight="bold" fill="#000000">postspkey</text><text x="76" y="246" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="9" fill="#666666">index, unique</text><line x1="326" y1="233" x2="326" y2="233" stroke="#000000" stroke-width="1" stroke-linecap="round"/><path d="M 326 160 C 326 196.5, 326 196.5, 326 233" stroke="#000000" stroke-width="1" fill="none"/><circle cx="326" cy="233" r="4" fill="#000000"/><rect x="28" y="260" width="670" height="54" fill="#f0f0f0"/><rect x="36" y="275" width="30" height="24" fill="#f0f0f0" stroke="#000000" stroke-width="1"/><text x="51" y="292" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="11" font-weight="bold" fill="#000000" text-anchor="middle">IX</text><text x="76" y="285" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="12" font-weight="bold" fill="#000000">postsauthorcreated</text><text x="76" y="300" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="9" fill="#666666">index</text><line x1="542" y1="287" x2="650" y2="287" stroke="#000000" stroke-width="1" stroke-linecap="round"/><path d="M 542 160 C 542 223.5, 542 223.5, 542 287" stroke="#000000" stroke-width="1" fill="none"/><circle cx="542" cy="287" r="4" fill="#000000"/><path d="M 650 160 C 650 223.5, 650 223.5, 650 287" stroke="#000000" stroke-width="1" fill="none"/><circle cx="650" cy="287" r="4" fill="#000000"/><text x="550" y="279" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="8" font-weight="bold" fill="#000000">1</text><text x="658" y="279" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="8" font-weight="bold" fill="#000000">2</text><rect x="36" y="329" width="30" height="24" fill="#f0f0f0" stroke="#000000" stroke-width="1"/><text x="51" y="346" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="11" font-weight="bold" fill="#000000" text-anchor="middle">IX</text><text x="76" y="339" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="12" font-weight="bold" fill="#000000">poststitleidx</text><text x="76" y="354" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="9" fill="#666666">index</text><line x1="434" y1="341" x2="434" y2="341" stroke="#000000" stroke-width="1" stroke-linecap="round"/><path d="M 434 160 C 434 250.5, 434 250.5, 434 341" stroke="#000000" stroke-width="1" fill="none"/><circle cx="434" cy="341" r="4" fill="#000000"/></svg> </div> A composite index reads left to right: postsauthorcreated 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. Related reading Diagram generators — every generator and its options Models — the definitions these are drawn from