Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- router.post('/getStances', function(req, res, next) {
- var text = '{"success":"0"}';
- text = queries.getStances(req.body.issues[0], req.body.issues[1], req.body.issues[2], req.body.issues[3]);
- var obj = JSON.parse(result);
- res.send(obj);
- });
- getStances: function (a, b, c, d) {
- var sendback = '{"stances":[';
- sendback += '{"1":[';
- var querytext = "SELECT * FROM allIssues WHERE topicname = '"+ a +"'";
- query = client.query(querytext,function (callback) {
- query.on('row', (row) => {
- sendback += "{" + '"'+row['topicstance']+'"' + " : " + '"'+ row['topicdescription'] + '"'+ "} , ";
- console.log(sendback);
- });
- });
- querytext = "SELECT * FROM allIssues WHERE topicname = '"+ b +"'";
- query = client.query(querytext);
- query.on('row', (row) => {
- sendback += "{" + '"'+ row['topicstance'] + '"'+ " : " + '"'+ row['topicdescription'] + '"'+ "} , ";
- });
- query.on('end', () => {
- sendback += "]}";
- sendback += "]}";
- client.end();
- return sendback;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement