# Mongodb aggregate data

**URL:** <https://discourse.nodered.org/t/mongodb-aggregate-data/25233>\
**Category:** General\
**Created:** [21 April 2020 10:02 UTC](https://discourse.nodered.org/t/mongodb-aggregate-data/25233 "2020-04-21T10:02:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apex](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@apex](https://discourse.nodered.org/u/apex)\
**Post date:** [21 April 2020 10:02 UTC](https://discourse.nodered.org/t/mongodb-aggregate-data/25233/1 "2020-04-21T10:02:09Z")

</div>

how can i aggregate the data in node red?

1. i am using node-red-contrib-mongodb2
2. 

```auto
[{"id":"a5d3fca9.1d6fb","type":"mongodb2 in","z":"17988aef.77ac65","service":"_ext_","configNode":"60e6b2b.5c7bc4c","name":"","collection":"cars","operation":"aggregate.toArray","x":670,"y":180,"wires":[["60a016a6.c089f8"]]},{"id":"60e6b2b.5c7bc4c","type":"mongodb2","z":"","uri":"mongodb://192.168.3.179:27017/testdb","name":"db","options":"","parallelism":"-1"}]

```

1. i didnt understand how

## Usage

Nodes to save and retrieve data in a local MongoDB instance.

Optionally, you may also (via a function) set

- a `msg.projection` object to constrain the returned fields,
- a `msg.sort` object,
- a `msg.limit` number,
- a `msg.skip` number.

You can either set the collection method in the node config or on `msg.collection` . Setting it in the node will override `msg.collection` .

this works ...

thanks if anyone can help~

---

<div class="post-metadata">

**Author:** ![divyansh](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/divyansh/32/20923_2.png) [@divyansh](https://discourse.nodered.org/u/divyansh)\
**Post date:** [2 May 2020 16:20 UTC](https://discourse.nodered.org/t/mongodb-aggregate-data/25233/2 "2020-05-02T16:20:37Z")

</div>

Hi @apex,  
I am kind of stuck in similar problem, did you find a solution to your problem ??

---

<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:** [1 July 2020 16:20 UTC](https://discourse.nodered.org/t/mongodb-aggregate-data/25233/3 "2020-07-01T16:20:47Z")

</div>

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