I have been trying to store the humidity and light values to a Mysql database, and displayed as a table 'mqtt', the flow is like this:
The sensed value is shown in msg.payload.payload_fields which are humidity and light, and the code of function node 'Create query in topic' is
var newmsg=new Date().toString(); msg.topic="INSERT INTO mqtt VALUES ('"+ new Date().toString() +"','"+ msg.payload.payload_fields.humidity +"','"+ msg.payload.payload_fields.light +"')"; return msg;
But there import an error:
I am confused of which part is wrong, maybe the code of function node. Thanks for your help!!!