I have looked, but am confused, so am not confident to my options.
The problem as it is now is like this:
I have data coming in from different places.
The msg.topic determines "who" sent it.
I used the topic because it leaves flexibility if/when I add more data sources.
But I've sort of shot myself in the foot with this.
I have a path to where the log files are. Then I get the msg.topic and add it to the path and all is sweet. The msg.topic has a / in it.
But I was wanting to have all files (as it turns out) not quite as per the topic's implied path.
So, the topic is "external/temperature"
I want to swap the / with a - so the file is "predetermined path" + "modified topic".
I am stuck on how to replace the / and replace it with - in a function node.
This is the idea.
var filename = "/home/pi/.node-red/public/databases/weather/";
var topic = msg.topic; // work needed here to replace the / with -
msg.filename = filename + topic + ".db";
var time = Date.now();
var x = msg.payload;
msg.payload = time + ' - ' + x;
return msg;
But I don't want the file stored in /home/pi/.node-red/public/databases/weather/external/temperature
More: /home/pi/.node-red/public/databases/weather/external-temperature.dbd
But I'm stuck how to.
I probably have been told, but I've forgotten.
I also think it is complicated because the / is a "special qualifier" and I can't remember how to get around that part too.