I am using the code below to search and filter the ‘name’ field in my database on a page of a site. I am needing this single search bar to search across the following fileds: name, sku, and description. How can I add to this code to make this possible?
import wixData from ‘wix-data’;
let debounceTimer;
export function input1_keyPress_1(event) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w(‘#input1’).value);
}, 200);
}
let lastFilterTitle;
function filter(title) {
if (lastFilterTitle !== title) {}
$w(‘#dataset1’).setFilter(wixData.filter().contains(‘name’, title))
}
Or just search an entire database and not a single field.
something like this…
export function searchbutton_click(event, $w) {
$w(“#dataset1”).onReady(() => {
let SearchValue = $w("#searchbox").value;
$w("#dataset1").setFilter(
wixData.filter()
.contains("collectionFieldKey1", SearchValue)
.or(
wixData.filter()
.contains("collectionFieldKey2", SearchValue)
.or(
wixData.filter()
.contains("collectionFieldKey3", SearchValue)
)
)
);
})
}
Thank you, that works perfect. You wouldn’t happen to know how to add this search to a store page would you? I have connected it to a grid with a repeater for the products on my store but of course there is no option to add to cart from there, which I really need.