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

How to handle deeper relations #43

Open
jannis6023 opened this issue Jul 26, 2023 · 1 comment
Open

How to handle deeper relations #43

jannis6023 opened this issue Jul 26, 2023 · 1 comment

Comments

@jannis6023
Copy link
Contributor

Hi,
just a question concerning usage and best practice using this generator.

I am using NestJS and Swagger - that's the reason I am using this generator for.
As the project grows, I have deeper relations, controlled by the include property in Prisma's find methods. How can I replicate them without having to have multiple classes with TypeIntersects and so on?

Is there a best practice I haven't read about?

Thanks in advance for any help!

Best regards

@joao-moonward
Copy link
Contributor

I think my approach could help you.:

class UserDto extends IntersectionType(
    PrismaModel.User,
    PickType(PrismaModel.UserRelations, ['address','documents']),
  )
  implements
    Prisma.UserGetPayload<{
      include: typeof UserDto.include;
    }>{


 static get include() {
    return Prisma.validator<Prisma.UserInclude>()({
      address: true,
      documents: true,
    })
 }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants