create local variables in build where and return as newly named
This commit is contained in:
parent
08cba77728
commit
db3b267657
15
index.js
15
index.js
@ -40,10 +40,13 @@ const SQLTemplate = (inSql, inJSON) => {
|
|||||||
}
|
}
|
||||||
return inSql;
|
return inSql;
|
||||||
};
|
};
|
||||||
const build_where = (req, c, w, d, args) => {
|
const build_where = (req, c, w) => {
|
||||||
//loop through each top level item expected to be a simple key/value list reflecting the column and the target value
|
//loop through each top level item expected to be a simple key/value list reflecting the column and the target value
|
||||||
// "part":"XFRM500", "customer":"Sanford and Son" --> SQL --> part = 'XFRM500'
|
// "part":"XFRM500", "customer":"Sanford and Son" --> SQL --> part = 'XFRM500'
|
||||||
// AND customer = 'Sanford and Son'
|
// AND customer = 'Sanford and Son'
|
||||||
|
var d = 1;
|
||||||
|
var args = [];
|
||||||
|
|
||||||
for (var i in req.body.app_scenario) {
|
for (var i in req.body.app_scenario) {
|
||||||
//console.log(i);
|
//console.log(i);
|
||||||
///console.log(req.body[i]);
|
///console.log(req.body[i]);
|
||||||
@ -71,7 +74,7 @@ const build_where = (req, c, w, d, args) => {
|
|||||||
args.push(req.body.app_scenario[i]);
|
args.push(req.body.app_scenario[i]);
|
||||||
c = c + 1;
|
c = c + 1;
|
||||||
};
|
};
|
||||||
return { c, w, d };
|
return { c, w };
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------route to test if the process is running-------------------------------
|
//------------route to test if the process is running-------------------------------
|
||||||
@ -110,11 +113,9 @@ server.get('/baseline', bodyParser.json(), function(req, res) {
|
|||||||
server.get('/scale', bodyParser.json(), function(req, res) {
|
server.get('/scale', bodyParser.json(), function(req, res) {
|
||||||
|
|
||||||
var sql = "";
|
var sql = "";
|
||||||
var w = ""; //holds the where
|
var where = ""; //holds the where
|
||||||
var c = 1; //flag if body is empty
|
var check = 1; //flag if body is empty
|
||||||
var d = 1;
|
|
||||||
var path = './routes/scale/scale.sql';
|
var path = './routes/scale/scale.sql';
|
||||||
var args = [];
|
|
||||||
|
|
||||||
|
|
||||||
fs.readFile(path, 'utf8', function(err, data) {
|
fs.readFile(path, 'utf8', function(err, data) {
|
||||||
@ -124,7 +125,7 @@ server.get('/scale', bodyParser.json(), function(req, res) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let { check, where } = build_where(req, c, w, d, args);
|
({ c: check, w: where } = build_where(req, check, where));
|
||||||
//if there was no body sent, return with nothing
|
//if there was no body sent, return with nothing
|
||||||
//if (c == 1) {
|
//if (c == 1) {
|
||||||
// res.send("no body was sent");
|
// res.send("no body was sent");
|
||||||
|
Loading…
Reference in New Issue
Block a user