Mermaid Builder
Write type-safe typescript code to generate mermaid er diagrams.
Usage
import { MermaidBuilder } from "mermaid-builder"
MermaidBuilder.create()
.add("Passengers", (p) => p.hasOne("Backpack"))
.add("Backpack", (b) => b.attribute("color", "blue"))
.add("Car", (car) =>
car
.hasMany("Passengers")
.hasOne("Driver", (D) => D.attribute("name", "John"))
)
.build()
Outputs:
erDiagram
Passengers {
}
Backpack {
color blue
}
Car {
}
Driver {
name John
}
Passengers ||--o{ Backpack : "hasOne"
Car ||--o{ Passengers : "hasMany"
Car ||--o{ Driver : "hasOne"
(mermaid code)
erDiagram
Passengers {
}
Backpack {
color blue
}
Car {
}
Driver {
name John
}
Passengers ||--o{ Backpack : "hasOne"
Car ||--o{ Passengers : "hasMany"
Car ||--o{ Driver : "hasOne"