Hey guys again,
my first issue was solved in an other thread here and to keep it a bit organized I just wanted to make a new thread on my following problem with my sql database. (old thread: Write variables to MariaDB (SQL Database) - General - Node-RED Forum (nodered.org))
According to this I was able to send a working topic/payload to the mysql database node to get an output without an error.
The problem I got now is that the entry for this specific device and room doesn't exist.
And I want to get something done like: If it exists, update it, if it doesn't create it.
This here is my working function node (for update) now:
const
device = "deskLED",
room = "office",
value = 0;
msg.topic = "UPDATE variables SET value = :value WHERE room = :room AND device = :device;"
msg.payload = {room, device, value}
return msg;
I played around with this syntax now and didn't get it to work:
msg.topic = "INSERT INTO variables SET value = :value WHERE room = :room AND device = :device ON DUPLICATE KEY UPDATE value = : value;"
msg.payload = {room, device, value}
But yeah as I already told you, the syntax is wrong.