Search code examples
postgresqlnestjsprisma

Prisma raw query return number instead of found value


This is the query that I am executing

const jobs = await this.prisma.$executeRaw`
SELECT
  name
 FROM 
  jobs 
 WHERE 
  status = 'ACTIVE'`;

but instead of getting the results that macth this query I only get a number, so the type of jobs is number and its value is 1. I am using postgresql


Solution

  • Try modifying your code to use the $queryRaw method instead;

    const jobs = await this.prisma.$queryRaw`
    SELECT
      name
     FROM 
      jobs 
     WHERE 
      status = 'ACTIVE'`;