Hi I’m new here and I’m trying to make a double filter on my store and I alway get the same error code.
the textBox filter’s working great but the problem come from my dropdown filter
if someone can tell me where is the problem and how to solved it it would be great thanks in advance
here’s the code and a screen shot of my Id and my Database name:
import wixData from 'wix-data';
$w.onReady(() => {
wixData.query('Collections')
.find()
.then(res => {
let options = [{"value": '', 'label': 'all Collections'}];
options.push(...res.items.map(collections => {
return {'value': collections.title, 'label': collections.title};
}));
$w('#iConsole').options = options;
})
})
let lastFilterTitle;
let lastFilterCollections;
let debounceTimer;
export function iTitle_keyPress(event, $w) {
if (debounceTimer) {
clearTimeout(debounceTimer);
debounceTimer = undefined;
}
debounceTimer = setTimeout(() => {
filter($w('#iTitle').value, lastFilterCollections);
}, 200);
}
function filter(title, collections) {
if (lastFilterTitle !== title || lastFilterCollections !== collections) {
let newFilter = wixData.filter();
if (title)
newFilter = newFilter.contains('name', title);
if (collections)
newFilter = newFilter.eq('collections', collections);
$w('#dataset1').setFilter(newFilter);
lastFilterTitle = title;
lastFilterCollections = collections;
}
}
export function iConsole_change(event, $w) {
filter(lastFilterTitle, $w('#iConsole').value);
}