-
Notifications
You must be signed in to change notification settings - Fork 602
Description
Hi.
Is there a way to insert more than 1 documents at one time?
This is example of my flow for inserting 1 document per trip (from function node to mongodb out node).
[ { "id": "ab1293da47f335a6", "type": "inject", "z": "e4313b973576809c", "name": "insert", "props": [ { "p": "payload" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "date", "x": 90, "y": 920, "wires": [ [ "60bbdc50c9cb93c2" ] ] }, { "id": "60bbdc50c9cb93c2", "type": "function", "z": "e4313b973576809c", "name": "insert function", "func": "let collection = 'daily-sale';\nlet payload = {\n 'day':1,\n 'sale': 1000,\n 'usage': 1000,\n 'collection': collection\n}\n\nlet obj = Object.assign({},payload);\nmsg.payload = obj;\nreturn msg.payload;", "outputs": 1, "timeout": 0, "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 260, "y": 920, "wires": [ [ "886a25611356b391" ] ] }, { "id": "886a25611356b391", "type": "mongodb out", "z": "e4313b973576809c", "mongodb": "2c97b2ee28fbe18e", "name": "mongodb", "collection": "", "payonly": false, "upsert": true, "multi": false, "operation": "insert", "x": 440, "y": 920, "wires": [] }, { "id": "2c97b2ee28fbe18e", "type": "mongodb", "hostname": "mongodb", "topology": "direct", "connectOptions": "", "port": "27017", "db": "db", "name": "" } ]
My objective is to reduce resource usage by using only 1 connection to mongodb to insert multiple documents at one time.
Thanks.