I’m working on a procedure that filters data based on the creation date within the last 24 hours. The code works perfectly when the date is explicitly specified within the procedure:
appReqscreated24H: protectedProcedure
.query(async ({ ctx }) => {
return await ctx.prisma.appRequest.count({
where: {
created_at: {
gte: new Date(Date.now() - 24 * 60 * 60 * 1000)
},
NOT: {
status: {
in: [RequestStatus.COMPLETE]
}
}
}
})
})
However, when I try to pass the date as an input parameter, the code doesn’t work as expected:
appReqscreated24H: protectedProcedure
.input(
z.object({
startDate: z.date()
})
)
.query(async ({ ctx, input }) => {
return await ctx.prisma.appRequest.count({
where: {
created_at: {
gte: input.startDate
},
NOT: {
status: {
in: [RequestStatus.COMPLETE]
}
}
}
})
}),
I’ve compared the types and they appear to be identical, yet I’m encountering issues with it not functioning as expected. As someone new to this, I would greatly appreciate any assistance.
Thank you in advance!