I followed the Wix Search a Database example ( https://www.wix.com/corvid/example/search-a-database ) to create a search bar for my database and removed the code for the dropdown menu. Right now, my code is set to just search for “authors” but I would like to add the ability to pull results based on multiple variables. For example, I would like to be able to expand the search from just “authors” to also search “description” and “title.” So, someone could type in “John Smith” or they could type in “mental health.” How do I do this?
import wixData from "wix-data";
let lastFilterauthor;
let debounceTimer;
export function iSearch_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#iSearch').value, lastFilterauthor);
}, 500);
}
function filter(author) {
if (lastFilterauthor !== author) {
let newFilter = wixData.filter();
if (author)
newFilter = newFilter.contains('author', author);
$w('#dataset1').setFilter(newFilter);
lastFilterauthor = author;
}
}