alexandrainst / node-red-contrib-postgresql

Node-RED node for PostgreSQL, supporting parameters, split, back-pressure
https://flows.nodered.org/node/node-red-contrib-postgresql
Apache License 2.0
32 stars 13 forks source link

return list of pg records successfully inserted as an array in msg.payload #17

Closed aMacDawg closed 2 years ago

aMacDawg commented 2 years ago

Use-case: As a Node-RED user with the postgres node installed, I am inserting records into a postgres database that assigns a UUID/GUID to each record as part of DB logic, therefore I need the list of pg records successfully returned in order to successfully perform additional updates on those records using the DB assigned UUID.

Current outcome: as a user of the postgres node, the only data returned from a successful INSERT is the msg.psql object which informs how many rows were impacted by the given operation, but no other data is returned.

Please let me know if I am missing something/need to assign a param somewhere. Thanks!

aMacDawg commented 2 years ago

This was actually a knowledge gap on my part: By appending RETURNING <column_name1>,<column_name2> in your SQL DML statement, you can return column names of the affected records in the msg.payload property.