notiz-dev/nestjs-prisma

Two different connections

cursan-a opened this issue · 2 comments

Hi,

On my project I need to open 2 postgresql connections (1 master, 1 read replica for analytics). I can't figure how to give a custom name when I instantiate a PrismaModule that allow me to inject PrismaService with the specified name.

I need something like :
whatever.module.ts

@Module({
  imports: [
    PrismaModule.forRootAsync({
      name: 'ANALYTICS_DATABASE'
...

whatever.service.js

@Injectable()
export class WhateverService {
  @Inject("ANALYTICS_DATABASE")
  private readonly prismaAnalytics!: PrismaService;
...

Is that possible with your implementation ?

Thank you in advance

Hi @cursan-a, checkout #40 as this is a new feature and you will need to use CustomPrismaModule and CustomPrismaService. Let me know if it works for you.

Closing this for now as it has the same solution as #31.