sql template string always returns string value

addDate: sql<number>cast (UNIX_TIMESTAMP(${schema.domain.addDate}) as signed), Hi,I have this in a select query but it always returns a string value "1695371020" even though it should be a number. Is there a way to get around it? Im using planetscale.
2 Replies
Angelelz
Angelelz13mo ago
You need to tell drizzle how to map it from the driver (string) to javascript You can do that with the mapWith() method:
addDate: sql<number>`cast
(UNIX_TIMESTAMP(${schema.domain.addDate}) as signed)`.mapWith(String),
addDate: sql<number>`cast
(UNIX_TIMESTAMP(${schema.domain.addDate}) as signed)`.mapWith(String),
DivMode
DivMode13mo ago
thanks, used .mapWith(Number) and it returns as number.
Want results from more Discord servers?
Add your server