varsql="SELECT jsonb_agg(regex) regex FROM tps.map_rm"
console.log(sql);
Postgres.query(sql,(err,res)=>{
if(err===null){
inRes.json(res.rows[0]);
return;
}
inRes.json(err.message);
});
}
);
//--------------------------------------------------------list unmapped items flagged to be mapped---------------------------------------------------
server.use("/unmapped",function(inReq,inRes){
varsql="SELECT jsonb_agg(row_to_json(x)::jsonb) regex FROM tps.report_unmapped_recs('";
sql+=inReq.query.srce+"') x"
console.log(sql);
Postgres.query(sql,(err,res)=>{
if(err===null){
inRes.json(res.rows[0]);
return;
}
inRes.json(err.message);
});
}
);
//-------------------------------------------------------------set source via json in body--------------------------------------------------------------------------
//validate the body contents before pushing to sql?
varsql="SELECT x.message FROM tps.srce_set($$";
sql+=JSON.stringify(inReq.body);
sql+="$$::jsonb) as x(message)";
console.log(sql);
Postgres.query(sql,(err,res)=>{
//Postgres.end();
if(err===null){
inRes.json(res.rows[0]);
return;
}
inRes.json(err.message);
//handle error
});
}
);
//-------------------------------------------------------------set one or more map definitions--------------------------------------------------------------------------
//validate the body contents before pushing to sql?
varsql="SELECT x.message FROM tps.srce_map_def_set($$";
sql+=JSON.stringify(inReq.body);
sql+="$$::jsonb) as x(message)";
console.log(sql);
Postgres.query(sql,(err,res)=>{
//Postgres.end();
if(err===null){
inRes.json(res.rows[0]);
return;
}
inRes.json(err.message);
//handle error
});
}
);
//-------------------------------------------------------------add entries to lookup table--------------------------------------------------------------------------