I store CQL filtering params as varchar in the database which i have to manipulate in JavaScript. street_desc
is a variable in javascript. How can i assign it to the string dynamically?
Whatever is inside the input_params
has to replace the cql_param string
var street_desc= "whatever"; //input from the user
var town_code = "whatever2"; //input from the user
var cql_param= "roadname_gr='street_desc'&towndesc is not null&town_code='town_code'"; //comes from database
var input_params = [street_desc,town_code]; //declare input params to replace the cql string
The output should be:
"roadname_gr='whatever'&towndesc is not null&town_code='whatever2'";
What i have tried...
var street_desc = "whatever"; //input from the user
var town_code = "whatever2"; //input from the user
var cql_param = "roadname_gr='street_desc'&towndesc is not null&town_code='town_code'"; //comes from database
var input_params = {
street_desc: street_desc,
town_code: town_code
}; //declare input params to replace the cql string
for (const [key, value] of Object.entries(input_params)) {
console.log(`${key}: ${value}`);
cql_param.replace(key, value);
}