# How to know all the collections of a database in mongodb using contrib-mongodb

**URL:** <https://discourse.nodered.org/t/how-to-know-all-the-collections-of-a-database-in-mongodb-using-contrib-mongodb/31622>\
**Category:** General\
**Created:** [16 August 2020 19:44 UTC](https://discourse.nodered.org/t/how-to-know-all-the-collections-of-a-database-in-mongodb-using-contrib-mongodb/31622 "2020-08-16T19:44:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![miobox](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/miobox/32/27075_2.png) [@miobox](https://discourse.nodered.org/u/miobox)\
**Post date:** [16 August 2020 19:44 UTC](https://discourse.nodered.org/t/how-to-know-all-the-collections-of-a-database-in-mongodb-using-contrib-mongodb/31622/1 "2020-08-16T19:44:01Z")

</div>

I am trying to query all the collections of a database in mongo to later search for data in each of the collections, someone knows how I can get all the collections using node-contrib-mongodb.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [17 August 2020 04:50 UTC](https://discourse.nodered.org/t/how-to-know-all-the-collections-of-a-database-in-mongodb-using-contrib-mongodb/31622/2 "2020-08-17T04:50:38Z")

</div>

Hi,

It seems that **node-contrib-mongodb** can not do this because the only operations it supports,  
are the ones in the image below

![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/d/1d1f2ace5c6a88a2c4372240c2a6cfded115cc23.jpeg)

I tested **node-red-contrib-mongodb3** though and it has a **db.listCollections.toArray** operation

test flow with mongodb3 below ( .. change node configuation to your db)

```auto
[
    {
        "id": "fe4fd1e2.2d51d",
        "type": "mongodb3 in",
        "z": "7d61deaf.f0703",
        "service": "_ext_",
        "configNode": "83016113.f363e",
        "name": "",
        "collection": "",
        "operation": "db.listCollections.toArray",
        "x": 800,
        "y": 680,
        "wires": [
            [
                "da9d3526.06dcd"
            ]
        ]
    },
    {
        "id": "da9d3526.06dcd",
        "type": "debug",
        "z": "7d61deaf.f0703",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1190,
        "y": 680,
        "wires": []
    },
    {
        "id": "c4c3b190.a06918",
        "type": "inject",
        "z": "7d61deaf.f0703",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{}",
        "payloadType": "json",
        "x": 360,
        "y": 680,
        "wires": [
            [
                "fe4fd1e2.2d51d"
            ]
        ]
    },
    {
        "id": "83016113.f363e",
        "type": "mongodb3",
        "z": "",
        "uri": "mongodb://127.0.0.1:27017/data",
        "name": "",
        "options": "",
        "parallelism": "-1"
    }
]

```

**ps**.. i dont know if its good practice to have both nodes installed .. maybe others can advise you on this.

---

<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:** [16 October 2020 04:50 UTC](https://discourse.nodered.org/t/how-to-know-all-the-collections-of-a-database-in-mongodb-using-contrib-mongodb/31622/3 "2020-10-16T04:50:41Z")

</div>

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