Problem
Having to use raw sql query when I would like to make use of a native database function.
Suggested solution
In my case I'm using Postgresql and would love to be able to use the extract function to retrieve information from a timestamp.
SELECT * FROM "Appointment" WHERE extract(month from timestamp) = 2;
I've done this with Mikro-orm in a prior project and a similar implementation with Prisma could look something like this:
prisma.appointment.findMany({ where: { "extract(month from timestamp)": 2 } as any });
Alternatives
My primary frustration with having to use a raw query is that the results of the query aren't mapped as they would be with a query using the API.
So an alternative could be an option to have raw queries also map the results of the query.
Problem
Having to use raw sql query when I would like to make use of a native database function.
Suggested solution
In my case I'm using Postgresql and would love to be able to use the extract function to retrieve information from a timestamp.
SELECT * FROM "Appointment" WHERE extract(month from timestamp) = 2;I've done this with Mikro-orm in a prior project and a similar implementation with Prisma could look something like this:
prisma.appointment.findMany({ where: { "extract(month from timestamp)": 2 } as any });Alternatives
My primary frustration with having to use a raw query is that the results of the query aren't mapped as they would be with a query using the API.
So an alternative could be an option to have raw queries also map the results of the query.