Skip to content

Commit

Permalink
chore: fix multiple instance of prisma client
Browse files Browse the repository at this point in the history
  • Loading branch information
mishraomp authored Jan 9, 2025
1 parent b90e611 commit f3dfaca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/src/prisma.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ const dataSourceURL = `postgresql://${DB_USER}:${DB_PWD}@${DB_HOST}:${DB_PORT}/$
@Injectable()
class PrismaService extends PrismaClient<Prisma.PrismaClientOptions, 'query'> implements OnModuleInit, OnModuleDestroy {
private logger = new Logger("PRISMA");

private static instance: PrismaService;
constructor() {
if (PrismaService.instance) {
return PrismaService.instance;
}
super({
errorFormat: 'pretty',
datasources: {
Expand All @@ -28,7 +31,7 @@ class PrismaService extends PrismaClient<Prisma.PrismaClientOptions, 'query'> im
{ emit: 'stdout', level: 'error' },
]
});

PrismaService.instance = this;
}


Expand Down

0 comments on commit f3dfaca

Please sign in to comment.