prisma-dbml-generator icon indicating copy to clipboard operation
prisma-dbml-generator copied to clipboard

Feature Request: Option to exclude relation fields

Open jon-lewis opened this issue 3 years ago • 2 comments

This request is similar to #33 but is different because I need the ability to exclude all relation fields from the generated DBML. Relation fields are not present in the database and can be confusing to consumers of my DBML.

For example, given the below schema

model User {
  id      Int      @id @default(autoincrement())
  posts   Post[]
  profile Profile?
}
model Profile {
  id      Int     @id @default(autoincrement())
  user    User    @relation(fields: [userId], references: [id])
  userId  Int
}
model Post {
  id         Int         @id @default(autoincrement())
  author     User        @relation(fields: [authorId], references: [id])
  authorId   Int
}

I need the DBML to be

Table User {
  id Int [pk, increment]
}

Table Profile {
  id Int [pk, increment]
  userId Int [unique, not null]
}

Table Post {
  id Int [pk, increment]
  authorId Int [not null]
}

Ref: Profile.userId - User.id

Ref: Post.authorId > User.id

jon-lewis avatar Jul 01 '22 20:07 jon-lewis

PR: https://github.com/notiz-dev/prisma-dbml-generator/pull/35

jon-lewis avatar Jul 01 '22 20:07 jon-lewis

@marcjulian is this something you're willing to add? I agree with @jon-lewis that this would be very useful for users.

MarceloPrado avatar Aug 30 '22 13:08 MarceloPrado