A nested include, drawn as the tree it actually is.The code#
new TreeDiagram({
title: 'include tree',
root: {
name: 'User',
children: [
{ name: 'Post', badge: 'hasMany', children: [
{ name: 'Comment', badge: 'hasMany' },
{ name: 'Tag', badge: 'belongsToMany' },
] },
{ name: 'Profile', badge: 'hasOne' },
],
},
}).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.Each level is another join. A tree this shape is where eager loading starts costing more than two queries would.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