Hi,
I have added a search bar with some code to my exercise database which is not working properly.
The code is:
import wixData from ‘wix-data’;
export function input2_keyPress(event, $w)
{
wixData.query(‘ExerciseDatabase’)
.ascending(“Exercise”)
.contains(‘Exercise’, $w(‘#input2’).value)
.find()
.then((res) => {
$w(‘#table2’).rows = res.items;
});
}
In the above code, ‘input2_keyPress’ is the search box in which I type, ‘ExerciseDatabase’ is the database collection name and ‘Exercise’ is the row name of exercises which I type in the search bar
I’m getting search results as I type text but it’s not showing accurately. When I press ‘Back Space’ button the search is not working properly and I’m just getting 50 records whereas I have 250 + records. Also it’s not showing exact results as I type and remove each character in the search box.
I watched the video ‘How to Create a Search for Your Database’ in Youtube, and also tried finding the solution in Wix Code Reference ( https://www.wix.com/code/reference ), but I’m not able to understand much as I dont know a lot about coding.
So can you please make some necessary changes in the code and help me out with it?