hari_narayan
hari_narayan
PPrisma
Created by hari_narayan on 1/25/2025 in #help-and-questions
Initialisation of prisma req based nestjs
return prismaService.$transaction(async (tx) => { // Wrap the transaction function to provide company-specific transaction context return fn(tx); }); }; } // Original method handling if (prop in target && typeof target[prop] === 'function') { return target[prop].bind(target); } return new Proxy( {}, { get: (_, methodProp) => { return async (...args: any[]) => { const prismaService = await this.moduleRef.resolve( PrismaReqService, originalContextId, ); return prismaService[prop]methodProp; }; }, }, ); }, }); } // Optional: Add utility method for complex transactions async runInTransaction<T>(fn: (tx: any) => Promise<T>): Promise<T> { const prismaService = await this.moduleRef.resolve( PrismaReqService, ContextIdFactory.getByRequest(this.request), ); return prismaService.$transaction(fn); } } upper helped me do anyoneKnow why and how to make it more resilient
12 replies
PPrisma
Created by hari_narayan on 1/25/2025 in #help-and-questions
Initialisation of prisma req based nestjs
import { Inject, Injectable } from '@nestjs/common'; import { ModuleRef, ContextIdFactory, REQUEST } from '@nestjs/core'; import { PrismaClient } from '@prisma/client'; import { PrismaReqService } from './company-prisma.service'; @Injectable() export class PrismaBaseService extends PrismaClient { constructor( private moduleRef: ModuleRef, @Inject(REQUEST) private readonly request: any, ) { super(); const originalContextId = ContextIdFactory.getByRequest(request); return new Proxy(this, { get: (target, prop) => { // Enhanced transaction handling if (prop === '$transaction') { return async (fn: any | any[]) => { const prismaService = await this.moduleRef.resolve( PrismaReqService, originalContextId, ); // Support both single and multiple transaction functions if (Array.isArray(fn)) { return prismaService.$transaction(fn); }
12 replies
PPrisma
Created by hari_narayan on 1/23/2025 in #help-and-questions
Gi,Migration 2 shemafiles...schma1.prisma
@RaphaelEtim thanks
11 replies
PPrisma
Created by hari_narayan on 1/23/2025 in #help-and-questions
Gi,Migration 2 shemafiles...schma1.prisma
11 replies
PPrisma
Created by hari_narayan on 1/23/2025 in #help-and-questions
Gi,Migration 2 shemafiles...schma1.prisma
Yes For that |Prisma |-schema1 |----------shema1.shema |-shema2 |----------shema2.shema |----------Migration |-------------------initialMig |---------------------mig.sql Like that above
11 replies
PPrisma
Created by hari_narayan on 1/23/2025 in #help-and-questions
Gi,Migration 2 shemafiles...schma1.prisma
Yes For that |Prisma |-schema1 |----------shema1.shema |-shema2 |----------shema2.shema Folder structure needed thanks Then migration folders will be created smoothly......
11 replies
PPrisma
Created by hari_narayan on 1/23/2025 in #help-and-questions
Gi,Migration 2 shemafiles...schma1.prisma
@RaphaelEtim thanks to reply sir will try it...and let u know....🙏🙏
11 replies
PPrisma
Created by hari_narayan on 1/23/2025 in #help-and-questions
Gi,Migration 2 shemafiles...schma1.prisma
@Prisma AI Help find again please
11 replies