When importing a service through the provider interface of the module, NestJS creates new instance each time that provider service is referenced.
For example if we have 20 modules which have PrismaService as a provider, a 20 instances of PrismaService will be created, which could result in many idle db connections.
To fix this:
Added PrismaModule which would export PrismaService
Replaced providers: [PrismaService] with imports: [PrismaModule] which ensures only a single instance of PrismaService is created.
When importing a service through the provider interface of the module, NestJS creates new instance each time that provider service is referenced.
For example if we have 20 modules which have PrismaService as a provider, a 20 instances of PrismaService will be created, which could result in many idle db connections.
To fix this: