skip to Main Content

I have a project that is using postgreSQL and Prisma. I was console.logging something in getServerSideProps(), but I noticed that is prisma is automatically console.logging huge amounts of strings like prisma:query SELECT "public"."TaskChart"."id", "public"."TaskChart"."name", "public"."TaskChart"."dateCreated", "public"."TaskChart"."default", "public"."TaskChart"."owner" FROM "public"."TaskChart" WHERE "public"."TaskChart"."owner" = $1 OFFSET $2 /* traceparent=00-00-00-00 */ How do I get rid of this?

2

Answers


  1. Try handling your prisma errors with this code :

    import { PrismaClient, Prisma } from '@prisma/client'
    
    const client = new PrismaClient()
    
    try {
      await client.user.create({ data: { email: '[email protected]' } })
    } catch (e) {
      if (e instanceof Prisma.PrismaClientKnownRequestError) {
        // The .code property can be accessed in a type-safe manner
        if (e.code === 'P2002') {
          console.log(
            'There is a unique constraint violation, a new user cannot be created with this email'
          )
        }
      }
      throw e

    Also check this reference

    Login or Signup to reply.
  2. Try checking your prisma instance.
    If it is like this:

    export const prisma = new PrismaClient({
        log:
          env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],
      });
    
    

    Then, remove log: from options.

    export const prisma = new PrismaClient();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search