Here is the project installation:
1. Nodejs server side environment
2. MySQL database (with Knexjs query builder)
3. 'locations'
table in a database with fields like 'country', 'city', 'category', 'working_hours'
.
4. Form input where user can select all these values and submit the search. When the user selects nothing, it defaults to 'ALL'. I need to filter the database and to select rows corresponding to the user search input.
I tried to do something like this:
knex('locations').where({
country: countryInput,
city: cityInput,
category: categoryInput,
working_hours: hoursInput
})
.then(function(rows) {.....})
.catch(function(err) {.....});
This works well if user selects all the input fields, what if the user selects only few of them and other are set to 'all'? How to make this work?
Thank you in advance!