Skip to content

New tag @minItems 1#12

Merged
samchon merged 1 commit intomasterfrom
features/examples
Nov 8, 2023
Merged

New tag @minItems 1#12
samchon merged 1 commit intomasterfrom
features/examples

Conversation

@samchon
Copy link
Copy Markdown
Owner

@samchon samchon commented Nov 8, 2023

Until yesterday, prisma-markdown could not distinguish whether 1: N relationships are mandatory or not. In such reason, prisma-markdown had drawn 1: N relationship as ||---|{ symbol regardless of the N position is whether mandatory or optional.

To make it clear, I've come with new idea @minItems 1 tag. If the tag being written on a 1: N relationship accessor, prisma-markdown will draw ||---|{ symbol. Otherwise it does not exist, ||---o{ symbol would be drawn instead.

model bbs_articles {
    id String @id @db.Uuid
    created_at DateTime @db.Timestamptz
    deleted_at DateTime? @db.Timestamptz

    //----
    // RELATIONS
    //----
    /// @minItems 1
    snapshots bbs_article_snapshots[]
    comments                bbs_article_comments[]
}
erDiagram
"bbs_articles" {
    String id PK
    DateTime created_at
    DateTime deleted_at "nullable"
}
"bbs_article_snapshots" {
    String id PK
    String bbs_article_id FK
    String format
    String title
    String body
    DateTime created_at
}
"bbs_article_comments" {
    String id PK
    String bbs_article_id FK
    String parent_id FK "nullable"
    DateTime created_at
    DateTime deleted_at "nullable"
}
"bbs_article_comment_snapshots" {
    String id PK
    String bbs_article_comment_id FK
    String format
    String body
    DateTime created_at
}
"bbs_article_snapshots" }|--|| "bbs_articles" : article
"bbs_article_comments" }o--|| "bbs_articles" : article
"bbs_article_comments" }o--o| "bbs_article_comments" : parent
"bbs_article_comment_snapshots" }|--|| "bbs_article_comments" : comment
Loading

Until yesterday, `prisma-markdown` could not distinguish whether 1: N relationships are mandatory or not. In such reason, `prisma-markdown` had drawn 1: N relationship as `||---|{` symbol regardless of the N position is whether mandatory or optional.

To make it clear, I've come with new idea `@minItems 1` tag. If the tag being written on a 1: N relationship accessor, `prisma-markdown` will draw `||---|{` symbol. Otherwise it does not exist, `||---o{` symbol would be drawn instead.

```typescript
model bbs_articles {
    id String @id @db.Uuid
    created_at DateTime @db.Timestamptz
    deleted_at DateTime? @db.Timestamptz

    //----
    // RELATIONS
    //----
    /// @minItems 1
    snapshots bbs_article_snapshots[]
    comments                bbs_article_comments[]
}
```
@samchon samchon added documentation Improvements or additions to documentation enhancement New feature or request labels Nov 8, 2023
@samchon samchon self-assigned this Nov 8, 2023
Copy link
Copy Markdown
Owner Author

@samchon samchon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, perfectly expressed.

@samchon samchon merged commit 3e34756 into master Nov 8, 2023
@samchon samchon deleted the features/examples branch November 8, 2023 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant