Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why relationFromFields are deleted from the mermaid model #135

Closed
Vitalii4as opened this issue Sep 7, 2022 · 3 comments
Closed

Why relationFromFields are deleted from the mermaid model #135

Vitalii4as opened this issue Sep 7, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@Vitalii4as
Copy link
Contributor

Hello, I'm trying to understand why some fields are removed during the generation of mermaid diagram. For example I have such a schema:

model User {
  id            String         @id
  email         String
  favoriteProducts  FavoriteProducts[]
}


model Product {
  id              String        @id
  title           String
  inFavorites  FavoriteProducts[]
}

model FavoriteProducts {
  userId      String
  user        User    @relation(fields: [userId], references: [id])
  productId   String
  product     Product @relation(fields: [productId], references: [id])

  @@id([userId, productId])
}

The generated mermaid diagram doesn't contain userId and productId. Is it possible to somehow show them?

erDiagram

  User {
    String id PK 
    String email  
    }
  

  Product {
    String id PK 
    String title  
    }
  

  FavoriteProducts {

    }
  
    FavoriteProducts o{--|| User : "user"
    FavoriteProducts o{--|| Product : "product"

I checked source code and they are filtered out in file src/generate.ts:178 - 182 Why it was done in such a way?

Thanks for your answer.

@keonik
Copy link
Owner

keonik commented Sep 8, 2022

I don't think there is anything wrong with either approach. I've seen both. This is built off of an existing algorithm that put emphasis on the connection lines and representing those relationships as opposed to having every foreign key in the models.

@keonik
Copy link
Owner

keonik commented Sep 8, 2022

If you'd like to add an option that would add those in feel free to send me a PR. I'm happy to add it in as long as it isn't going to change everyone's current ERD's

@keonik keonik added the enhancement New feature or request label Sep 8, 2022
@Vitalii4as
Copy link
Contributor Author

Here is the PR #136

@keonik keonik closed this as completed in f36325b Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants