prisma-class-validator-generator icon indicating copy to clipboard operation
prisma-class-validator-generator copied to clipboard

Provide option to separate between relations and fields

Open omar-dulaimi opened this issue 2 years ago • 2 comments

Discussed in https://github.com/omar-dulaimi/prisma-class-validator-generator/discussions/3

Originally posted by ErlanggaDewa July 13, 2022 There is an option to seperate between the relationship and the field??

I want to seperate StudentProfile relationship from the model (ApproveRequest.model.ts) to become ApproveRequest.model.ts and ApproveRequestRelationship.model.ts. Because your program still make the relationship field into one files

Example prisma schema case 👇

model ApproveRequest {
  id                String  @id @unique @default(uuid()) @map("id")
  identifyNumber    String  @map("identify_number") @db.VarChar(100)
  requestDate       String  @map("request_date") @db.VarChar(50)

  StudentProfile StudentProfile? @relation(fields: [identifyNumber], references: [identifyNumber])

}

My expected 2 files output 👇

ApproveRequest.model.ts

export class ApproveRequest {
  @IsDefined()
  @IsString()
  id!: string;

  @IsDefined()
  @IsString()
  identifyNumber!: string;

}

and

ApproveRequestRelationship.model.ts

export class ApproveRequestRelationship {
  @IsOptional()
  StudentProfile?: StudentProfile;
}

it's help me, or you can make some option like :

  1. seperate relation
  2. relation and and other field become 1 files (like your program now)
  3. not generating relation field

Originally posted by @ErlanggaDewa in https://github.com/omar-dulaimi/prisma-class-validator-generator/discussions/3#discussioncomment-3165615

omar-dulaimi avatar Jul 20 '22 21:07 omar-dulaimi

Hello @erlanggadewa

Do you still need this?

omar-dulaimi avatar Apr 12 '24 15:04 omar-dulaimi

@omar-dulaimi yes, i still need this. thanks for remind me

erlanggadewa avatar Apr 13 '24 01:04 erlanggadewa