Home > Software engineering >  queryRaw don't show data on prisma
queryRaw don't show data on prisma

Time:04-11

is there prisma developers here?

 const users = await prisma.$queryRaw`SELECT * FROM User`;

queryraw doesn't work for me, data appear on prisma studio and there is no problem but when I try to run the query above, It only shows my postgres username. When I check my data on psql, It shows the same, tables appear but there is no data inside.

enter image description here

enter image description here

thanks in advance for those who'll help ;)

CodePudding user response:

You would need to pass the database schema name while fetching data through Raw Query.

Like this:

 const users = await prisma.$queryRaw`SELECT * FROM "public"."User"`;

This should solve your issue.

CodePudding user response:

$queryRunUnsafe is function and must be pass sql query as argument

const users= await prisma.$queryRawUnsafe(sql);

  • Related