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

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.

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

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)

[
    {
        "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.

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