This package provides Node-RED nodes for interacting with MongoDB databases, enabling users to store and retrieve data within their Node-RED flows. It abstracts the complexities of the MongoDB driver, allowing operations like `find`, `count`, `aggregate`, `save`, `insert`, `update`, and `remove` via message properties (`msg.payload`, `msg.query`, `msg.collection`). Originally part of Node-RED core, it was spun out as a separate installable package from Node-RED v0.10.8 onwards. The current stable version is 0.8.0, with a release cadence that seems to follow major Node-RED or MongoDB driver updates, marked by 'Milestone Release' entries. Key differentiators include its tight integration with the Node-RED flow paradigm and simplified database interactions for IoT and data processing scenarios. It requires a running MongoDB server and depends on a MongoDB client package version 3.6.3 or newer.
npm install node-red-node-mongodbNo compatibility data collected yet for this library.
Demonstrates programmatic MongoDB interaction using the underlying driver, paralleling the operations provided by the Node-RED node, and provides installation steps for the Node-RED package itself.
Run `npm install node-red-node-mongodb` in your Node-RED user directory (typically `~/.node-red`).
Remove any older `mongodb` client packages by running `npm remove mongodb` in your Node-RED user directory before installing `node-red-node-mongodb`.
If idempotent behavior is desired (i.e., overwriting existing documents), ensure `msg._id` is set to a constant or derived unique identifier in a preceding function node before the message reaches the MongoDB output node.
Always provide a specific `msg.payload` query object for 'Remove' operations unless a complete collection wipe is explicitly intended. Implement confirmation steps in your Node-RED flow for critical delete operations.
To use this package, install it within your Node-RED environment (e.g., `npm install node-red-node-mongodb` in `~/.node-red`) and then drag and configure the MongoDB nodes from the Node-RED palette.
In your Node-RED user directory (`~/.node-red`), run `npm remove mongodb` followed by `npm install node-red-node-mongodb` to ensure a compatible client version is installed.
In a Node-RED function node prior to the MongoDB 'out' node, set `msg.payload._id` (if sending `msg.payload`) or `msg._id` (if sending `msg` object) to a unique and consistent identifier for the document you intend to update or save idempotently.
Verify that your MongoDB server is running and accessible from the Node-RED machine. Double-check the connection string in the MongoDB node's configuration within the Node-RED editor for correct hostname, port, and any necessary credentials.
Ensure the username and password configured for the MongoDB connection are correct and have the appropriate read/write access to the target database and collections.