From 136bb030c90fa2c6ec3c4d1412beafc27ad4b9c3 Mon Sep 17 00:00:00 2001 From: fleetside72 Date: Mon, 3 Dec 2018 14:53:37 -0500 Subject: [PATCH] treat inbound json as array of targets to oterate through call db func on each --- server.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 5bb2e14..398546e 100644 --- a/server.js +++ b/server.js @@ -54,8 +54,11 @@ server.get("/source", function (inReq, inRes) //returns message about status and error description server.post("/source", bodyParser.json(), function (inReq, inRes)// remove body parsing, just pass post body to the sql string build { - var sql = "SELECT x.message FROM tps.srce_set($1::jsonb) as x(message)"; - Postgres.FirstRow(sql,[JSON.stringify(inReq.body)], inRes); + x = inReq.body; + for (var i =0; i < x.length; i++) { + var sql = "SELECT x.message FROM tps.srce_set($1::jsonb) as x(message)"; + Postgres.FirstRow(sql,[JSON.stringify(x[i])], inRes); + } }); //----------------------------------------------------------regex instrUctions-------------------------------------------------------------------------------------------------------------------------