节点红色错误:无法创建属性' _msgid'在字符串上

时间:2017-05-22 16:38:24

标签: mysql sql mqtt node-red mosquitto

我在Node Red中设置了这个: enter image description here

使用此SQL(函数)代码:

msg.topic = "INSERT INTO temperature(temp, date) VALUES('" + 
msg.payload + "', 'NOW()')";

return msg.topic;

收到此错误:

function : (error)
"TypeError: Cannot create property '_msgid' on string 'INSERT INTO 
temperature(temp, date) VALUES('1.23', 'NOW()')'"

我做错了什么?

1 个答案:

答案 0 :(得分:2)

你的函数只是返回一个字符串(msg.topic),它需要返回一个完整的对象。

msg.topic = "INSERT INTO temperature(temp, date) VALUES('" + msg.payload + "', 'NOW()')";

return msg;