how can i make the query more proffesional
so basically i am tying to get all posts with a particular type of post but same route also serve as the route for search so this complicated things
i want to be able to all the post with the particular post type provided and still use same route to filter the post
3 Replies
you can filter directly in the prisma query https://www.prisma.io/docs/concepts/components/prisma-client/case-sensitivity
Prisma
Case sensitivity (Reference)
How Prisma Client handles case sensitivity when filtering and sorting.
also, why do you allow input to be null, but then return nothing, then it is. Just remove nullish() in the zod schema and remove the first line of the query
also, use zod to check if
postType
is valid, don't do it inside the querypostype is the first required param for query
firstly filter all post by postType
then if they is a query use it to search the result the of first query
and the postType is table looks like this