1 year ago

#386399

test-img

justLearning

how to separate business logic from prisma logic

I have just started using Prisma as an orm, in my project, but I am not sure how to separate the Prisma queries and logic code from the service logic that's using Prisma, since we can't use the generic repositories approach, I would like to find a workaround to achieve this decoupling, any ideas?

this is an example of an 'application. service' using Prisma

>  async findByIdPrisma(applicationId: number):
> Promise<ApplicationModel> {
>     const application = await this.prismaService.application.findUnique({
>       where: { id: applicationId },
>     });
>     if (application) {
>       return application;
>     }
>     throw new DataIsForbiddenOrNotFoundException('Application', {
>       Application: applicationId,
>     });   }

the solution that I want to achieve is having those queries as functions in a separate repository having it totally decoupled from this service, thanks in advance

typescript

postgresql

nestjs

prisma

separation-of-concerns

0 Answers

Your Answer

Accepted video resources