Skip to content

Commit

Permalink
Merge pull request #13 from simonireilly/release/0.0.3
Browse files Browse the repository at this point in the history
Version 0.0.3 release with Plantuml support and better README documentation
  • Loading branch information
simonireilly authored Jun 10, 2022
2 parents abe5cb8 + 122f254 commit 52116e2
Show file tree
Hide file tree
Showing 6 changed files with 417 additions and 5 deletions.
191 changes: 190 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,199 @@
Generating ERD for TypeORM data sources in Mermaid JS or PlantUML

- [TypeORM ERD](#typeorm-erd)
- [Example](#example)
- [Usage](#usage)
- [Examples](#examples)
- [Shoulders](#shoulders)

<!-- embedme ./example.mermaid -->

## Example

A complex ERD with join tables can be visualized.

```mermaid
erDiagram
cart_item {
bigint id PK
bigint productId FK
bigint cartId FK
varchar sku
float price
float discount
smallint quantity
tinyint active
datetime createdAt
datetime updatedAt
text content
}
category {
bigint id PK
bigint parentId FK
varchar title
varchar metaTitle
varchar slug
text content
}
product_meta {
bigint id PK
bigint productId FK
varchar key
text content
}
product_review {
bigint id PK
bigint productId FK
bigint parentId FK
varchar title
smallint rating
tinyint published
datetime createdAt
datetime publishedAt
text content
}
tag {
bigint id PK
varchar title
varchar metaTitle
varchar slug
text content
}
product {
bigint id PK
bigint userId FK
varchar title
varchar metaTitle
varchar slug
tinytext summary
smallint type
varchar sku
float price
float discount
smallint quantity
tinyint shop
datetime createdAt
datetime updatedAt
datetime publishedAt
datetime startsAt
datetime endsAt
text content
}
order_item {
bigint id PK
bigint productId FK
bigint orderId FK
varchar sku
float price
float discount
smallint quantity
datetime createdAt
datetime updatedAt
text content
}
transaction {
bigint id PK
bigint userId FK
bigint orderId FK
varchar code
smallint type
smallint mode
smallint status
datetime createdAt
datetime updatedAt
text content
}
order {
bigint id PK
bigint userId FK
varchar sessionId
varchar token
smallint status
float subTotal
float itemDiscount
float tax
float shipping
float total
varchar promo
float discount
float grandTotal
varchar firstName
varchar middleName
varchar lastName
varchar mobile
varchar email
varchar line1
varchar line2
varchar city
varchar province
varchar country
datetime createdAt
datetime updatedAt
text content
}
user {
bigint id PK
enum role
varchar firstName
varchar middleName
varchar lastName
varchar mobile
varchar email
varchar passwordHash
tinyint admin
tinyint vendor
datetime registeredAt
datetime lastLogin
tinytext intro
text profile
}
cart {
bigint id PK
bigint userId FK
varchar sessionId
varchar token
smallint status
varchar firstName
varchar middleName
varchar lastName
varchar mobile
varchar email
varchar line1
varchar line2
varchar city
varchar province
varchar country
datetime createdAt
datetime updatedAt
text content
}
product_category {
bigint categoryId PK
bigint productId PK
}
product_tag {
bigint productId PK
bigint tagId PK
}
cart_item }|--|| cart: cart
cart_item }|--|| product: product
category }|--|| category: parent
category ||--|{ product_category: products
product_meta }|--|| product: product
product_review }|--|| product_review: parent
product_review }|--|| product: product
tag ||--|{ product_tag: products
product }|--|| user: user
product ||--|{ product_category: categories
product ||--|{ product_tag: tags
order_item }|--|| order: order
order_item }|--|| product: product
transaction }|--|| order: order
transaction }|--|| user: user
order }|--|| user: user
cart }|--|| user: user
```

## Usage

Currently programmatic usage is the only supported usage method:
Expand Down Expand Up @@ -42,7 +231,7 @@ main();

## Examples

Checkout the examples in ![./examples.md](./examples.md) and the source code for the examples in ![./examples.ts](./examples.ts)
Checkout the examples in [./examples.md](./examples.md) and the source code for the examples in [./examples.ts](./examples.ts)

## Shoulders

Expand Down
179 changes: 179 additions & 0 deletions example.mermaid
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
erDiagram
cart_item {
bigint id PK
bigint productId FK
bigint cartId FK
varchar sku
float price
float discount
smallint quantity
tinyint active
datetime createdAt
datetime updatedAt
text content
}
category {
bigint id PK
bigint parentId FK
varchar title
varchar metaTitle
varchar slug
text content
}
product_meta {
bigint id PK
bigint productId FK
varchar key
text content
}
product_review {
bigint id PK
bigint productId FK
bigint parentId FK
varchar title
smallint rating
tinyint published
datetime createdAt
datetime publishedAt
text content
}
tag {
bigint id PK
varchar title
varchar metaTitle
varchar slug
text content
}
product {
bigint id PK
bigint userId FK
varchar title
varchar metaTitle
varchar slug
tinytext summary
smallint type
varchar sku
float price
float discount
smallint quantity
tinyint shop
datetime createdAt
datetime updatedAt
datetime publishedAt
datetime startsAt
datetime endsAt
text content
}
order_item {
bigint id PK
bigint productId FK
bigint orderId FK
varchar sku
float price
float discount
smallint quantity
datetime createdAt
datetime updatedAt
text content
}
transaction {
bigint id PK
bigint userId FK
bigint orderId FK
varchar code
smallint type
smallint mode
smallint status
datetime createdAt
datetime updatedAt
text content
}
order {
bigint id PK
bigint userId FK
varchar sessionId
varchar token
smallint status
float subTotal
float itemDiscount
float tax
float shipping
float total
varchar promo
float discount
float grandTotal
varchar firstName
varchar middleName
varchar lastName
varchar mobile
varchar email
varchar line1
varchar line2
varchar city
varchar province
varchar country
datetime createdAt
datetime updatedAt
text content
}
user {
bigint id PK
enum role
varchar firstName
varchar middleName
varchar lastName
varchar mobile
varchar email
varchar passwordHash
tinyint admin
tinyint vendor
datetime registeredAt
datetime lastLogin
tinytext intro
text profile
}
cart {
bigint id PK
bigint userId FK
varchar sessionId
varchar token
smallint status
varchar firstName
varchar middleName
varchar lastName
varchar mobile
varchar email
varchar line1
varchar line2
varchar city
varchar province
varchar country
datetime createdAt
datetime updatedAt
text content
}
product_category {
bigint categoryId PK
bigint productId PK
}
product_tag {
bigint productId PK
bigint tagId PK
}
cart_item }|--|| cart: cart
cart_item }|--|| product: product
category }|--|| category: parent
category ||--|{ product_category: products
product_meta }|--|| product: product
product_review }|--|| product_review: parent
product_review }|--|| product: product
tag ||--|{ product_tag: products
product }|--|| user: user
product ||--|{ product_category: categories
product ||--|{ product_tag: tags
order_item }|--|| order: order
order_item }|--|| product: product
transaction }|--|| order: order
transaction }|--|| user: user
order }|--|| user: user
cart }|--|| user: user
Loading

0 comments on commit 52116e2

Please sign in to comment.