Dynamic data filtering, one filter disables other filters

I have a repeater setup for visitors to filter multiple different dropdowns to find exactly what they are looking for. However, I am struggling to add a dropdown for price less than or equal to set values. It somewhat works but dominates the other filters and filters things it shouldn’t be affecting.

import wixData from 'wix-data';

export function searchButton_click(event) {
    search();
}

function search() {

    wixData.query("Items").contains("brand", String($w('#dropdown1').value))
    .and(wixData.query("Items").contains("movement", String($w('#dropdown2').value)))
    .and(wixData.query("Items").contains("caseMaterial", String($w('#dropdown3').value)))
    .and(wixData.query("Items").contains("diameter", String($w('#dropdown4').value)))
    .and(wixData.query("Items").le("price", String($w('#dropdown5').value)))
    
        .find()
        .then(results => {
            $w('#listRepeater').data = results.items;
        })
}

export function resetButton_click(event) {
  $w('#dynamicDataset').setFilter(wixData.filter());
    $w('#dropdown1').value = undefined;
    $w('#dropdown2').value = undefined;
    $w('#dropdown3').value = undefined;
    $w('#dropdown4').value = undefined;
    $w('#dropdown5').value = undefined;
}

Any help would be greatly appreciated.

  1. You do not need to add all the time → . and ( wixData . query ( “Items” )…
    …if you are reffering always to the same DATABASE.

Just do like…

wixData.query("Items")
    .contains("brand", String($w('#dropdown1').value))
    .contains("movement", String($w('#dropdown2').value))
    .contains("caseMaterial", String($w('#dropdown3').value))
    .contains("diameter", String($w('#dropdown4').value))
    .le("price", String($w('#dropdown5').value))
    .find()
    .then(results => {$w('#listRepeater').data = results.items;})
    .catch((err)=>{console.log(err);});

Since you are using an AND-FILTER it is not a surprising, that you think that your …

.le("price", String($w('#dropdown5').value));

…dominates all the other filters.

What does this code do ?

  1. searching for all what contains → dropdown1-value inside of DB-FIELD(“brand”)
  2. searching for all what contains → dropdown2-value inside of DB-FIELD(“movement”)
  3. searching for all what contains → dropdown3-value inside of DB-FIELD(“caseMaterial”)
  4. searching for all what contains → dropdown4-value inside of DB-FIELD(“diameter”)

…AND ALSO…

  1. searching for all what is LOWER or EQUALS → dropdown5-value inside of DB-FIELD(“price”)

But wait!!! → Your PRICE is also a STRING ???

.le("price", String($w('#dropdown5').value));

This will never work with a STRING!!!

MAYBE → Number(…) ???

Thank you for your help

It solved your issue?