Jessica Otte
02/11/2022, 6:35 PMeffectiveDate DateTime? @map("effective_date") @db.Date
• Query looks like
const courses: Course[] = await prisma.$queryRaw<Course[]>`
SELECT
id,
course_number,
effective_date as "effectiveDate",
....
But if I try and do effectiveDate.getDate() or something, I get a runtime error; and if I console.log typeof effectiveDate
, it tells me that it's a string. If I do my query using prisma.findMany
, it works fine.
I do see in the docs it says
Type caveats when using raw SQL: When you type the results of $queryRaw, the raw data does not always match the suggested TypeScript type.So, is it expected behavior that the date returns as a string, or am I doing something wrong? And if it matters,
prisma --version
gives me
prisma : 3.0.1
@prisma/client : 3.7.0
Current platform : windows