There should be no need to store them in the db, feed them into the
nodes that need them and save them in context variables. Then they
are immediately available when another input is fed into the node.
This is the pattern I use in numerous function nodes that need to take
action based on a number of inputs. Each time it is used it is only
necessary to setup the contents of requiredInputs. I tried to work
out how to use the merge node to do the same thing but did not manage
to achieve it.
// these are the topics that need to be provided before we can do anything
// and the context var names to save them in
var requiredInputs = {
"some_topic/name1": "name1",
"some_topic/name2": "name2",
"etc": "etc"
};
// see if msg.topic is one of the inputs we have to save
for (var topic in requiredInputs) {
if (msg.topic == topic) {
// yes it is so save it
context.set(requiredInputs[topic], msg.payload);
break;
}
}
// whatever the message was, see if we have all the data we need to carry on
var allOK = true;
for (var topic in requiredInputs) {
if (typeof context.get(requiredInputs[topic]) === 'undefined') {
allOK = false;
break;
}
}
if (allOK) {
// if we get here then we know we have got up to date values for all
the topics in requiredInputs
// available using context.get("name1") etc
...
Colin
> --
>
http://nodered.org
>
> Join us on Slack to continue the conversation:
http://nodered.org/slack
> ---
> You received this message because you are subscribed to the Google Groups
> "Node-RED" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
node-red+u...@googlegroups.com.
> To post to this group, send email to
node...@googlegroups.com.
> Visit this group at
https://groups.google.com/group/node-red.
> To view this discussion on the web, visit
>
https://groups.google.com/d/msgid/node-red/9c6e76ff-d3f9-4188-9ede-c5d410ca519b%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.