Search dropdown

Dear All,
I am trying to code as the tutorial Wix Code | How to Create a Search for Your Database - YouTube
but does not work.

I have two database, BooksCategory and whitepapers.
BooksCategory has a field key → category
whitepapers has also a field
I have created a repeater that shows title and category of white papers stored in the database whitepapers.
I want to allow the user to search by entering a keyword in a input box or selecting a category from a dropdown menu.

This is the code I have created

import wixData from ‘wix-data’;

$w.onReady(() => {
wixData.query(‘BooksCategory’)
.find()
.then(res =>
{
let options = [{“value”: ‘’, ‘label’: ‘All Categories’}];
options.push(…res.items.map(category => {
return {‘value’: category.title, ‘label’: category.title};
}))
$w(‘iCategory’).options = options;
}
)
});

let LastFilterTitle;
let LastFilterCategory;
let debounceTimer;

export function iTitle_keyPress(event, $w)
{
if (debounceTimer)
{
clearTimeout (debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout (() =>
{
filter($w(‘#iTitle’).value, LastFilterCategory);
}, 200);
}

function filter(title, category)
{
if (LastFilterTitle !== title || LastFilterCategory !== category)
{
let newFilter= wixData.filter();
if (title)
newFilter = newFilter.contains(‘category’, title);
if (category)
newFilter = newFilter.eq(‘category’, category);
$w(‘#dataset1’).setFilter(newFilter);
LastFilterTitle = title;
LastFilterCategory = category;
}
}

export function iCategory_change(event, $w) {
filter(LastFilterTitle, $w(‘#iCategory’).value);
}

what is wrong here?

You can use the Example: Search a Database as a starting point. Load this example into your editor and you can see how it runs, and you can modify it and adapt it to your own needs.

Good luck,

Yisrael