omar-dulaimi / prisma-class-validator-generator

Prisma 2+ generator to emit typescript models of your database with class validator
MIT License
71 stars 11 forks source link

Provide option to separate between relations and fields #5

Open omar-dulaimi opened 2 years ago

omar-dulaimi commented 2 years ago

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 commented 5 months ago

Hello @erlanggadewa

Do you still need this?

erlanggadewa commented 5 months ago

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