# Linking nodes with wire

**URL:** <https://discourse.nodered.org/t/linking-nodes-with-wire/43097>\
**Category:** Developing Nodes\
**Created:** [23 March 2021 21:55 UTC](https://discourse.nodered.org/t/linking-nodes-with-wire/43097 "2021-03-23T21:55:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [23 March 2021 21:55 UTC](https://discourse.nodered.org/t/linking-nodes-with-wire/43097/1 "2021-03-23T21:55:18Z")

</div>

I have a question about linking nodes with wires.  
For example I have three nodes A,B,C and this nodes are linked to node D with wire.  
Every node has a unique internal id.  
On node property "wires" of nodes A,B,C are the id of node D.  
How can node D determine how many nodes are linked to his input ?  
In this case 3.  
Is there an easy JavaScript example for that ?  
Thanks

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [23 March 2021 22:07 UTC](https://discourse.nodered.org/t/linking-nodes-with-wire/43097/2 "2021-03-23T22:07:05Z")

</div>

This isn't typically information a node should need to care about. In the runtime, there is no easy way for a node to know what it is wired to. You'd have to get ahold of the complete flow configuration and parse it out to figure out what is connected to what.

In the editor, there are APIs to find wires connected to any particular node you could use.

So it depends what you are trying to do, and why.

---

<div class="post-metadata">

**Author:** ![iiot2k](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiot2k](https://discourse.nodered.org/u/iiot2k)\
**Post date:** [23 March 2021 22:18 UTC](https://discourse.nodered.org/t/linking-nodes-with-wire/43097/3 "2021-03-23T22:18:18Z")

</div>

Thanks Nick for answer,  
Nodes A,B,C are sending boolean values.  
Node D processed the boolean information and send the result if all nodes send.  
For that I must know, how many nodes are connected to input.  
For example node D checks for a AND, OR, XOR logical condition of nodes A,B,C

---

<div class="post-metadata">

**Author:** ![cinhcet](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cinhcet/32/438_2.png) [@cinhcet](https://discourse.nodered.org/u/cinhcet)\
**Post date:** [23 March 2021 23:14 UTC](https://discourse.nodered.org/t/linking-nodes-with-wire/43097/4 "2021-03-23T23:14:30Z")

</div>

This node here [node-red-contrib-boolean-logic (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-boolean-logic) solves that having the number of messages as a config option

If you want to automate that, you have to be careful about partial deploys. Not sure a node is reinitialized if only a wire to it was added/removed.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 May 2021 23:15 UTC](https://discourse.nodered.org/t/linking-nodes-with-wire/43097/5 "2021-05-22T23:15:20Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
