Creating a dynamic query

Hello everyone, we have a page with 3 user input options,
default option is all, and the user can choose another option.
than I want to create a query based on user choices.
my problem is if the user did not change the default “all” value, I don’t want to query about this specific field, what means that could be 3 different conditions for the query but it also could be 1 ,2 or even no conditions.

how can I “append” to a query like in SQL?

So:

let query = wixData.query("COLLECTION").eq("name", $w("#nameInput").value);
if($w("#dropdown1").value !== "all"){
    query = query.eq("myFieldKey", $w("#dropdown1").value);
}
query.find()
.then(res => {
//etc..

Thanks a lot!

You’re welcome :slight_smile: