logoalt Hacker News

vvpan05/15/20252 repliesview on HN

How do you do typed raw queries?


Replies

campbellmorgan05/15/2025

https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/r... - it assumes that these queries return arrays and there's a template you can pass in like this:

prisma.$queryraw<YourType>`SELECT * FROM ...`

show 1 reply
seer05/15/2025

Check out the docs https://www.prisma.io/docs/orm/prisma-client/using-raw-sql/t... it generates output types, though input types still need to be done by you via type comments in the sql