extension-read-replicas icon indicating copy to clipboard operation
extension-read-replicas copied to clipboard

Add debug mode, for understand on which db request was sended

Open cherniavsky94w opened this issue 2 years ago • 2 comments

cherniavsky94w avatar Nov 06 '23 11:11 cherniavsky94w

A debug mode, or a way to log the queries will really help. For example, I have a NestJs project with two different services, one for write and another for read only. In the service for write I can do this this.prisma.$on('query', console.log); to see the query and the parameters. But the $on method doesn't exists when I create the prisma client like this:

const prisma = new PrismaClient({
  log: [
    {
      level: 'query',
      emit: 'event',
    },
  ],
}).$extends(readReplicas({ url: String(process.env.DATABASE_READ_URL) }));

Did I created the client right? And is there any way to log the queries?

jacsonrsasse avatar Dec 29 '23 12:12 jacsonrsasse

Hope to merge the PR #30 for logging too

tim80411 avatar Mar 01 '24 03:03 tim80411

Aforementioned PR got merged and released, there is a logging example in README now: https://github.com/prisma/extension-read-replicas#pre-configured-clients

SevInf avatar Jul 24 '24 15:07 SevInf