{"id":43454,"library":"node-red-contrib-mongodb4","title":"node-red-contrib-mongodb4","description":"A Node-RED node that wraps the native MongoDB Node.js driver (v6) for database operations without limitations. Version 3.4.0 is current stable. Released on npm with monthly cadence. Unlike other Node-RED MongoDB nodes, this exposes full driver API via a flow node, supporting all CRUD, aggregation, and admin operations. Requires Node-RED >=3.0.0 and Node.js >=16.20.1. Compatible with MongoDB server versions 4.0-8.0.","status":"active","version":"3.4.0","language":"javascript","source_language":"en","source_url":"https://github.com/steineey/node-red-contrib-mongodb4","tags":["javascript","node-red","nodes","mongodb"],"install":[{"cmd":"npm install node-red-contrib-mongodb4","lang":"bash","label":"npm"},{"cmd":"yarn add node-red-contrib-mongodb4","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-red-contrib-mongodb4","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core MongoDB driver v6.12 used for all database operations","package":"mongodb","optional":false}],"imports":[{"note":"These are Node-RED nodes, not standard JS modules. They are loaded by Node-RED runtime from the package's nodes directory.","wrong":"Manual require or import in Node-RED function nodes","symbol":"Node-RED node types (mongodb-config and mongodb-flow)","correct":"Install package via npm in .node-red directory; nodes appear in palette automatically"}],"quickstart":{"code":"// Example: Insert one document into a MongoDB collection using the flow node\n// Set operation to 'insertOne' and provide payload as an array:\nmsg.payload = [{ name: 'Anna', age: 25 }];\nreturn msg;\n\n// Example: Find documents with query and options\nconst query = { age: { $gte: 18 } };\nconst options = { sort: { name: 1 }, limit: 5 };\nmsg.payload = [query, options];\nreturn msg;\n\n// Example: Aggregate pipeline\nconst pipeline = [\n  { $match: { age: { $gte: 18 } } },\n  { $group: { _id: '$city', count: { $sum: 1 } } }\n];\nmsg.payload = [pipeline];\nreturn msg;","lang":"javascript","description":"Demonstrates how to pass operation arguments via msg.payload array in Node-RED flow node."},"warnings":[{"fix":"Review the official MongoDB Node.js driver v6 upgrade guide: https://www.mongodb.com/docs/drivers/node/current/upgrade/#version-6.0-breaking-changes","message":"Version 3.x uses MongoDB driver v6 which includes breaking changes from driver v5. For example, MongoClient constructor no longer accepts callback; only use new MongoClient(url).","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always wrap arguments in an array: msg.payload = [document] not msg.payload = document.","message":"The operation argument must be passed as an array inside msg.payload, even for a single argument like insertOne. Forgetting the array wrapper leads to incorrect function call.","severity":"gotcha","affected_versions":"all"},{"fix":"Use msg.payload = [pipeline];","message":"When using aggregation, the pipeline is itself an array, so msg.payload must be an array containing that array: msg.payload = [pipeline];","severity":"gotcha","affected_versions":"all"},{"fix":"Always set msg.payload to an array of arguments for the MongoDB driver method.","message":"The field 'msg.payload' is used for operation arguments; this overrides the standard Node-RED pattern where msg.payload is the main data. The node expects a very specific payload structure.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"search_vec":"'-8.0':72 '16.20.1':65 '3.0.0':62 '3.4.0':25 '4.0':71 'admin':56 'aggreg':54 'api':46 'cadenc':34 'compat':66 'contrib':4 'crud':53 'current':27 'databas':20 'driver':17,45 'expos':43 'flow':49 'full':44 'javascript':73 'limit':23 'mongodb':15,40,68,78 'mongodb4':5 'month':33 'nativ':14 'node':2,8,10,38,41,50,60,75,77 'node-r':7,37,59,74 'node-red-contrib-mongodb4':1 'node.js':16,64 'npm':31 'oper':21,57 'red':3,9,39,61,76 'releas':29 'requir':58 'server':69 'stabl':28 'support':51 'unlik':35 'v6':18 'version':24,70 'via':47 'without':22 'wrap':12","created_at":"2026-06-05T16:59:52.552550+00:00","updated_at":"2026-06-05T16:59:52.552550+00:00","problems":[{"fix":"Change msg.payload = pipeline; to msg.payload = [pipeline];","cause":"Passed pipeline directly as msg.payload instead of wrapping it in an array.","error":"MongoError: cannot use non-array argument with aggregate"},{"fix":"Verify credentials and ensure authSource matches the database where the user is defined.","cause":"Invalid username/password or wrong authSource.","error":"MongoError: (Unauthorized) Authentication failed"},{"fix":"Check network connectivity and MongoDB server status; verify host/port in config node.","cause":"MongoDB server is not reachable at the given host/port.","error":"MongoError: connect ECONNREFUSED"},{"fix":"Check connection settings and ensure the config node shows connected status in the editor.","cause":"The config node failed to establish a connection, so the client is undefined or not properly initialized.","error":"TypeError: client.db is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/steineey/node-red-contrib-mongodb4#readme","github":"https://github.com/steineey/node-red-contrib-mongodb4","docs":null,"changelog":null,"pypi":null,"npm":"node-red-contrib-mongodb4","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}