Hi all! Is there any way to convert a `Prisma.Prod...
# orm-help
s
Hi all! Is there any way to convert a
Prisma.ProductWhereInput
into a raw WHERE statement? Or to get the SQL for a call like
prisma.product.find_many({ where })
?
👀 1
✅ 1
n
Hey Santi 👋 You can get the SQL for all Prisma queries by enabling logging. Here’s an example to enable logs:
Copy code
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient({
  log: ['query'],
});
Here’s a sample output for a create query:
Copy code
prisma:query BEGIN
prisma:query INSERT INTO "public"."User" ("username") VALUES ($1) RETURNING "public"."User"."id"
prisma:query SELECT "public"."User"."id", "public"."User"."username" FROM "public"."User" WHERE "public"."User"."id" = $1 LIMIT $2 OFFSET $3
prisma:query COMMIT
{ id: 3, username: 'alice' }