I'm stuck; how do I create a searchable database?

I have created a database named “SpectraDatabase” and am currently trying to make a form on a dynamic page associated with this database. The form simply contains multiple fields that the user will enter information, and then clicks the “search” button. I want it so that the user isn’t required to enter information for all fields and the search will only run on the fields that the user has typed something for. After the “search” button is clicked, I want the website redirect to a different webpage where the results are shown.

I tried to type the code for this but I am stuck as it has only been a few hours since I started learning about javascript. What am I doing wrong?

Thanks in advance.


import wixData from ‘wix-data’;

export function button1Click(event){
wixData.query(“SpectraDatabase”)
.contains(“compoundName”, $w(“#compoundNameField”).value)
.eq(“title”, $w(“#msdNo”).value)
.eq(“molecularFormula”, $w(“#molecFormula”).value)
.between(“molecularWeight”, $w(“#minMolecWeight”).value, $w(“#maxMolecWeight”).value)
.find()
.then(res => {
// I’m stuck here
});
}


.then(res => {
console.log(res.items)
});

1.publish your site.
2. go to that page and refresh it.
3. right click and click on “inspect” choose “console”.
4. press the button1 and see what “console” gives you as output.