I am working on integrating MQTT Topic with Postgres DB on Node-Red.I have one MQTT Topic for e.g 'query/topic1' which is getting some value from a publisher, I want to save this value into Postgres database.For that, I created flow on Node-Red.I have created MQTT subscriber component which is feeding 'function' block which in turn is input to Postgres.I have written below function in 'function' component (named 'query' in the image) in Node-Red.
msg.payload = [
{
query: 'begin',
},
{
query: 'select * from table1 where field2 > $param1',
params: {
param1: $msg.payload,
},
output: true,
},
{
query: 'commit',
},
];
return msg;
I want the "$param1" to be the value coming from MQTT topic, but I am confused how to do that.I tried using '$msg.payload' but it did not work.Can you please suggest. I am new to these stuffs.
