prisma / extension-read-replicas

Prisma Client Extension to add read replica support to your Prisma Client
Apache License 2.0
101 stars 6 forks source link

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

Closed cherniavsky94w closed 2 months ago

jacsonrsasse commented 9 months ago

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?

tim80411 commented 7 months ago

Hope to merge the PR #30 for logging too

SevInf commented 2 months ago

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