# Help with Jsonata grouping please

**URL:** <https://discourse.nodered.org/t/help-with-jsonata-grouping-please/23616>\
**Category:** General\
**Created:** [25 March 2020 12:39 UTC](https://discourse.nodered.org/t/help-with-jsonata-grouping-please/23616 "2020-03-25T12:39:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JayNaire](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaynaire/32/17343_2.png) [@JayNaire](https://discourse.nodered.org/u/JayNaire)\
**Post date:** [25 March 2020 12:39 UTC](https://discourse.nodered.org/t/help-with-jsonata-grouping-please/23616/1 "2020-03-25T12:39:10Z")

</div>

[grouping.json](https://discourse.nodered.org/uploads/short-url/4ftZxeEtqptJFBHidsJ0MzQKoJe.json) (97.7 KB) shows two Change Nodes using Jsonata being used to de-duplicate log entries.

The first node groups & amends objects from a log by (day) date, the second strips off the date key produced by that grouping such that a simple array of objects is produced; exactly like the input.

It works fine. (There a 8 or 9 fewer elements in the clean output array than the input.)

However, I feel it's a bit feeble having to use two nodes but I couldn't find a syntax / method of grouping without having to use that grouping (day/date in this case) as an output key somewhere.

I'd be very grateful for any thoughts.

---

<div class="post-metadata">

**Author:** ![realjax](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/realjax/32/895_2.png) [@realjax](https://discourse.nodered.org/u/realjax)\
**Post date:** [25 March 2020 17:32 UTC](https://discourse.nodered.org/t/help-with-jsonata-grouping-please/23616/2 "2020-03-25T17:32:29Z")

</div>

I am not 100 % sure that I understand your question, but to me it seems the easiest way would be to hande the data sequence as a stream and take a more functional approach. Take a look at Lodash's [chain](https://lodash.com/docs/4.17.15#chain) command. It will provide a very clean way to solve your problem.

---

<div class="post-metadata">

**Author:** ![JayNaire](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/jaynaire/32/17343_2.png) [@JayNaire](https://discourse.nodered.org/u/JayNaire)\
**Post date:** [27 March 2020 14:26 UTC](https://discourse.nodered.org/t/help-with-jsonata-grouping-please/23616/3 "2020-03-27T14:26:22Z")

</div>

**Many, many thanks** for your reply @realjax, my apologies if I was not clear but you understood well and chaining was indeed the answer, in fact `~> function($i){$i.*}` was all that was required.

I'm really chuffed at finding an answer but also depressed at how many times I've read the documentation without fully realising the implications!

---

<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:** [26 May 2020 14:26 UTC](https://discourse.nodered.org/t/help-with-jsonata-grouping-please/23616/4 "2020-05-26T14:26:22Z")

</div>

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