Discussion on how to create a search function in a custom movie app using Next.js and Sanity.io.
26 replies
Last updated: Nov 29, 2022
B
Is it possible to make a search query entered by the User, in my custom movie based app (not the one used as a template) ?
Nov 28, 2022, 9:24 AM
It is! You can pass in a variable using params. For example:
const query = `*[_type == 'movie' && title = $title] const params = { title: <user-entered-term-here> } const results = await client.fetch(query, params)
Nov 28, 2022, 6:07 PM
B
user M
I am not sure, how will I be able to take user input and pass it through query.Nov 28, 2022, 6:09 PM
B
I am still a beginner
Nov 28, 2022, 6:09 PM
B
Ohh it's Next the best
Nov 28, 2022, 6:10 PM
Great! You'll need to create a controlled form that will allow you to hold whatever value the user enters in state. Then you can pass that variable to your params.
Nov 28, 2022, 6:12 PM
B
Ohh
user M
that was great explanation, I will get back to you if I am facing any issues but huge ThanksNov 28, 2022, 6:13 PM
B
user M
Are there any examples regarding this problem statement, I am still not sure what to write and where to write.Nov 28, 2022, 6:29 PM
I don't think anyone has put together a guide for this particular use case. Can you share the code in your frontend where you'd like to add this?
Nov 28, 2022, 6:46 PM
B
Ohh sure
Nov 28, 2022, 6:47 PM
B
user M
I want to make search function here for the whole dataset.Nov 28, 2022, 6:48 PM
B
Nov 28, 2022, 6:48 PM
B
Sure sir
Nov 28, 2022, 6:52 PM
B
user M
Did you got some time to making my project betterNov 29, 2022, 12:07 PM
B
??
Nov 29, 2022, 12:07 PM
Nope, it was unfortunately a very busy day in the community yesterday. I'll try to take a look today.
Sidenote: I'm guessing you used 'sir' to be polite, but my pronouns are listed in my Slack name (feminine or gender neutral). I'm assuming this was an accident, but please don't misgender people in the community.
Sidenote: I'm guessing you used 'sir' to be polite, but my pronouns are listed in my Slack name (feminine or gender neutral). I'm assuming this was an accident, but please don't misgender people in the community.
Nov 29, 2022, 4:17 PM
B
user M
Ohh I am really sorry, It was a mistake, don't mind me.šNov 29, 2022, 4:27 PM
B
Sorry Ma'am
Nov 29, 2022, 4:28 PM
B
It would be great if you pls take a look at it.
Nov 29, 2022, 4:29 PM
Will do! Just have to wrap up my morning meetings, then I'll be able to take a look.
Nov 29, 2022, 4:30 PM
B
Yes I do got the required the help
user M
Nov 29, 2022, 7:01 PM
Sanityā build remarkable experiences at scale
Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.