I have some WIX Data Queries in my backend code and I now want to add three if statements and depending on which execute different data queries. What is best practise doing this?
if (statement === value) {
run query1
} else {
run query2
}
Do I have to create a function that will only execute a data query and return resulsts after the then and make a new function for each different query?
Sometimes I want to chain eq but in some cases lt and I want to change these with code.
This is a matter of design. I recommend splitting the queries to different functions so that in case there’s an issue with a certain scenario, it’ll be easier to fix it. Note that you can use also a switch statement instead of multiple if else statements for that matter.
Adn it works perfect and I must say you are so right, all the functions and different queries make more sense in separate functions. Easier to maintain and modify as well.