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
Matvey
Matvey2y ago
Prisma
Case sensitivity (Reference)
How Prisma Client handles case sensitivity when filtering and sorting.
Matvey
Matvey2y ago
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 query
Lopen
Lopen2y ago
postype 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
model PostType {
id String @id @default(cuid())
name String @unique
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
Post Post? @relation(fields: [postId], references: [id])
postId String?
model PostType {
id String @id @default(cuid())
name String @unique
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
Post Post? @relation(fields: [postId], references: [id])
postId String?
Want results from more Discord servers?
Add your server