How do I add a search button to database?

I have a Wix database that has 42K zip code inputted. I would like to add a search to the data base for visitors to be able to search it. I have seen this feature down using Wix code but can’t seem to get it to work or I keep getting a error on the same line.

This is database setup:


This is the code I’ve done:

Any help on this or possibly what is wrong on line 12?

Thanks

Hello,

Here we have a great example of the Database Search that you can open in your Editor, play with it, adjust to your needs and implement on your site.

We also have a step-by-step tutorial on how to implement Search or Filters on your site:
Corvid: About Creating Searches and Filters of Displayed Data

Regarding your code, please double-check the syntax of the relevant APIs using the links below:
https://www.wix.com/code/reference/wix-data.html#query
https://www.wix.com/corvid/reference/wix-data.WixDataFilter.html#contains
https://www.wix.com/corvid/reference/wix-data.html#filter

Good luck!

did you figure it out? I have been struggling with my search also.

For basic search as you type, this is the code you need.
You don’t have to add this ‘or’ when you have to search either.

To do integrated filtering out of all fields if that’s what you mean, it’s a little more complex.
You will need to do a separate search function, with each field running on all fields.

import wixData from 'wix-data';

export function input17_keyPress(event){
$w("#dataset1").setFilter( wixData.filter()
  .contains("zip", $w("#input17").value))
.then( () => {
  console.log("Dataset is now filtered");
} )
.catch( (err) => {
  console.log(err);
} );

}

Could you check my code? I’m coding a job board, and want to implement a search for a position title. I’ve tried a few different methods offered on the wix forum & the example, but for some reason can’t get it. The search doesn’t load at all in preview.

import wixData from 'wix-data';

export function search_keypress(event){
$w("#dynamicDataset").setFilter( wixData.filter()
  .contains("positionTitle", $w("#search").value))
.then( () => {
  console.log("Dataset is now filtered");
} )
.catch( (err) => {
  console.log(err);
} );

}

This is what I edited based off of your example.

Your excellent code should work well. I assume you are using an independent input field and a search from an independent database. With this code you do not need the WIX built-in search feature
Some things need to be certain.
That the database is set to read, and that there is content in the database (live or in preview times).
The question also is how do you present things at the end? In the table? In repiters?