How to filter data from prisma in app directory
Unanswered
Saadat Ali posted this in #help-forum
Hi Developers, it's been 3 days I'm trying to find a way to make a functional search form. I have a list of todos on page.tsx and fetching these todos using prisma. How to filter these todos when the user submits the search form. I'm not able to understand if I need to use server actions or something else.
Thanks â¤ï¸
#help-forum #discussions
Thanks â¤ï¸
#help-forum #discussions
3 Replies
@Saadat Ali Hi Developers, it's been 3 days I'm trying to find a way to make a functional search form. I have a list of todos on page.tsx and fetching these todos using prisma. How to filter these todos when the user submits the search form. I'm not able to understand if I need to use server actions or something else.
Thanks â¤ï¸
<#1007476603422527558> <#752647196419031042>
When the user types in the search form, wait for some time(ideally 300ms) then use router.replace and push to same route but with the text as query parameter. Inside server component, check if there is a query parameter, if yes apply the filter else return normal result
[Read More here with code example](https://nextjs-faq.com/sharing-client-side-state-with-server-components)
Hmmm that's genius.. let me apply