'use strict'; const request = require('request'); const db = require('../app/db') const logger = require('../app/logger'); var members_action = { refreshActions: function (req, res, next) { logger.info(req.query); let Qstring = "SELECT id,uid,updated from members ORDER BY updated ASC LIMIT 2"; logger.info( Qstring ); db.query(Qstring, function (err, result) { try { if (err) throw err; if (result.rowCount > 0 ){ result.rows.map( (rw)=>{ console.log(rw); console.log(rw["uid"]); const insertQuery = 'INSERT INTO members_actions(members_id, members_uid, action_label,action_name,status_description,status ) VALUES($1, $2, $3, $4, $5, %6)' var Querydata = { "members_id":res.rows[0], "members_uid": res.rows[1], "action_label": 'Systems Status Checks ', "action_name": 'system_status_checks', "status_description": 'processing', "status": 0 }; db.query(insertQuery, Querydata, (err, res) => { if (err) { console.log(err.stack) } else { console.log(res.rows[0]) } }) }) } let resultItem ={ "result": result.rows, "total_record": result.rowCount } // logger.info(result); next(null, resultItem); // pass control to the next handler } catch (e) { next(e.message, null); // pass control to the next handler } }); }, updateSelection: async function (){ logger.info("Ameye-Called -The-Function") } }; module.exports = members_action;