How to recover a value from SQL queries in javascript -
i have function javascript
, compare 2 values of 2 turnover of 2 results sql queries
. problem function return 1 line knowing have more 300 lines. tihs following code:
var query1 = {{repair_semestre1}}; var query2 = {{repair_semestre2}}; var data = {}; [query1, query2].foreach(function (query, semester) { query.client.foreach(function(clientid, index) { var client = data[clientid] = data[clientid] || {}; var clientart = client[query.lru[index]] = client[query.lru[index]] || [0, 0]; clientart[semester] = query.round[index]; }); }); // report on data (client in data) { (article in data[client]) { var turnovers = data[client][article]; return("client: " + client + ", art.: " + article + ", semester t/o: " + turnovers + " " + (turnovers[0] === turnovers[1] ? "equal" : turnovers[0] < turnovers[1] ? "increase" : "decrease")); } }
the values of 2 sql queries
change dynamically according choice of user in interface, values of line returned function above change. can please tell me why function return 1 line ? thank you.
it worked now, changed this:
var query1 = {{repair_semestre1}}; var query2 = {{repair_semestre2}}; var data = {}; [query1, query2].foreach(function (query, semester) { query.client.foreach(function(clientid, index) { var client = data[clientid] = data[clientid] || {}; var clientart = client[query.lru[index]] = client[query.lru[index]] || [0, 0]; clientart[semester] = query.round[index]; }); }); // report on data var output = []; (client in data) { (article in data[client]) { var turnovers = data[client][article]; output.push(formatname(client,article,turnovers)); } } return { output: output }; function formatname(client,article,turnover) { return("client: " + client + ", art.: " + article + ", semester t/o: " + turnovers + " " + (turnovers[0] === turnovers[1] ? "equal" : turnovers[0] < turnovers[1] ? "increase" : "decrease")); }
maybe because, on palantir have special syntax. thank @trincot.
Comments
Post a Comment