# Batch node use case example

**URL:** <https://discourse.nodered.org/t/batch-node-use-case-example/18079>\
**Category:** General\
**Created:** [17 November 2019 22:17 UTC](https://discourse.nodered.org/t/batch-node-use-case-example/18079 "2019-11-17T22:17:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ab73863](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ab73863/32/11144_2.png) [@ab73863](https://discourse.nodered.org/u/ab73863)\
**Post date:** [17 November 2019 22:17 UTC](https://discourse.nodered.org/t/batch-node-use-case-example/18079/1 "2019-11-17T22:17:05Z")

</div>

Hi ,

I am a newbie to node-red and I am trying to understand the usages of each node . I couldn't find any examples around batch node to understand the use case where the node fits in . I read through the brief definition and the 3 modes of operation which technically able to understand but on a realtime use case I am not able to find a story.

When I tried using the batch node with debug i could see the output from batch node but I was in an assumption that each batch is having specific unique id. But the response I am observing is all having same id (message id).

# Flow

Inject node --\> Function node(code give below) --\> batch node(sequence by number of message ,set as 2) --\> Debug node

# Function node code

for(var i=0; i\<4 ;i++){  
node.send({payload:i});  
}  
return msg;

Could you please share any examples or link directing to the usage of a batch node.

Regards  
Arun

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 November 2019 22:46 UTC](https://discourse.nodered.org/t/batch-node-use-case-example/18079/2 "2019-11-17T22:46:08Z")

</div>

When debugging, use the 'complete msg object' to see the full message.

The batch node is used in conjunction with the join node. Each message in the batch gets a `msg.parts` with an index and a count number. The join node can use the index and the count to create a (new) merged object, new string, array etc.

---

<div class="post-metadata">

**Author:** ![ab73863](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ab73863/32/11144_2.png) [@ab73863](https://discourse.nodered.org/u/ab73863)\
**Post date:** [17 November 2019 22:48 UTC](https://discourse.nodered.org/t/batch-node-use-case-example/18079/3 "2019-11-17T22:48:01Z")

</div>

Thanks @bakman2 for the quick response.

Let me give a try in conjunction with the join node.

Regards  
Arun
