Hey all
So, I have a multiselect component and it has a bunch of values in it like ["a","b","c"]. When these values are unselected, I want to set values of the columns in the DB to 0. My JS code is:
<script>
var tagsTot = ["a", "b", "c"];
document.write("SET ")
for (var i=0; i<=tagsTot.length-1; i=i+1) {
document.write(tagsTot[i]);
if (i <= tagsTot.length-2){
document.write(" = '0', ");
}
else{
document.write(" = '0' ");
}
}
</script>
Which has the result of:
SET a = '0', b = '0', c = '0'
I want to use this result in my PostgreSQL query. Many thanks in advance.