npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prisma-generator-plantuml-erd

v1.6.0

Published

Provide a description about your generator

Downloads

1,625

Readme

prisma-generator-plantuml-erd

Prisma generator to create an ER Diagram for plantuml.

You can generate the plantuml source code from the schema.prisma.

example

  • schema.prisma
    • https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/schema.prisma
  • generated plantuml file
    • https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example.puml
  • generated image file
    • https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example/erd.svg

usage

npm i -D prisma-generator-plantuml-erd
# or
yarn add -D prisma-generator-plantuml-erd

Add to your schema.prisma

generator erd_plantuml {
  provider   = "prisma-generator-plantuml-erd"
  output = "erd.puml"
  exportPerTables      = true
  showUniqueKeyLabel = true
  isShowForeignKeyOnRelation = true
  // markdownOutput       = "./example-tables.md"
  // markdownIncludeERD      = true
  // asciidocOutput       = "./example-tables.adoc"
  // asciidocIncludeERD      = true
}

Please refer to the Options section for the meaning of each option and set them accordingly.

Run the generator

$ npx prisma generate

Options

output

The path of generated plantuml file path. The default value is './erd.puml'

usePhysicalTableName

If this flag is true, physical table name is used for name of table on er diagram. The default value is false;

model User {
  id            String         @id

  @map("users")
}

If this flag is set to true, then "users" will be displayed on the diagram, otherwise "User" is displayed on the diagram.

exportPerTables

If this flag is true, generate some tables If this flag is true, it also generate some diargrams that based on each table. The diagrams is rendered with only the tables that related with base table. The default value is false.

example

  • all tables
    • https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example/erd.svg
  • related with User table
    • https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example/User.svg
  • related with Team table
    • https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/prisma/example/Team.svg

lineLength

You can change the length of relation line by this option. The default value is '--'.

In the default case

Table1 }o--o| Table3

if you set this flag to '---'

Table1 }o---o| Table3

showUniqueKeyLabel

If this flag is true, unique column is also labeled as unique key on er diagram, like [UK]. The default value is false.

lineType

This parameter is used to change the type of relation line. You can choose from the following three options:

  • ortho
  • polyline
  • unset

The default value is ortho.

isShowForeignKeyOnRelation

When set to true, foreign keys will be displayed on the relation lines. The default value is false.

isLeftToRightDirection

When set to true, PlantUML's left to right direction will be specified. The ER diagram will be drawn vertically. This can be specified to improve the layout if the diagram becomes too wide horizontally.

additionalPlantUMLParams

This is used when you want to specify options provided by PlantUML that are not individually prepared. When setting multiple options, separate them with ; as shown below, and they will be expanded line by line.

additionalPlantUMLParams = "scale 1280 width; hide circle;skinparam classFontColor red;skinparam classFontSize 10;skinparam classFontName Aapex;"
hide circle;skinparam classFontColor red;skinparam classFontSize 10;skinparam classFontName Aapex;

markdownOutput

If this flag is set, a markdown table definition will be generated as well.

example

  • https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/example-tables.md

The generated Markdown file can be converted to HTML or PDF using the following Docker image.

https://github.com/dbgso/docker-markdown-to-pdf-with-figures

markdownIncludeERD

If this flag is true, an ER diagram for each table is generated on the table definitions The default value is false.

asciidocOutput

If this flag is set, a asciidoc table definition will be generated as well.

example

  • https://raw.githubusercontent.com/dbgso/prisma-generator-plantuml-erd/main/packages/usage/example-tables.adoc

asciidocIncludeERD

If this flag is true, an ER diagram for each table is generated on the table definitions The default value is false.

Example

The example config is here.

generator erd_plantuml {
  provider   = "prisma-generator-plantuml-erd"
  output               = "path/to/output.puml"
  lineLength           = "----"
  exportPerTables      = true
  usePhysicalTableName = false
  showUniqueKeyLabel = true
  markdownOutput       = "./example-tables.md"
  markdownIncludeERD      = true
  asciidocOutput       = "./example-tables.adoc"
  asciidocIncludeERD      = true
}