Registry / database / n8n-nodes-mongo

n8n-nodes-mongo

JSON →
library1.0.8jsnpmunverified

A community node for n8n that adds advanced MongoDB operations including findOne, findMany, insert, update, delete, singleton pooling, automatic ObjectId conversion, and aggregation support. Version 1.0.8 is the latest stable release. This node is designed for n8n workflow automation, providing a richer set of MongoDB features than the built-in node, with a focus on performance and ease of use. Key differentiators include connection pooling and direct ObjectId handling.

npm install n8n-nodes-mongo
INSTALL
IMPORT
SIG · N8N-NODES-MONGO
N
n8n-nodes-mongo
databasejavascriptv1.0.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

mongo
import { mongo } from 'n8n-nodes-mongo'
import mongo from 'n8n-nodes-mongo'
The package exports a named export 'mongo' for the node class. Default import will not work.
MongoNode
import { MongoNode } from 'n8n-nodes-mongo'
If you prefer importing the class under a different alias. The node is exported as both 'mongo' and 'MongoNode'.

Shows usage of the MongoDB node in an n8n workflow, including credential setup and node configuration for a findMany operation with query and options.

import { mongo } from 'n8n-nodes-mongo'; // Use in n8n workflow configuration const credential = { name: 'MongoDB', data: { connectionString: process.env.MONGODB_URI ?? 'mongodb://localhost:27017', database: process.env.MONGODB_DB ?? 'mydb', }, }; const node = { name: 'MongoDB', type: 'n8n-nodes-mongo.mongo', typeVersion: 1, position: [250, 300], credentials: { mongo: credential, }, parameters: { operation: 'findMany', collection: 'users', query: JSON.stringify({ status: 'active' }), options: JSON.stringify({ limit: 10, sort: { name: 1 } }), }, }; // Export for n8n workflow ecosystem export { node };
Debug
Known issues
gotchaThe node expects connection string and database in credentials. Ensure these are provided.
fix
In n8n, create a MongoDB credential with the required fields.
affects: >=1.0.0
gotchaAutomatic ObjectId conversion only works for fields named '_id' or ending with 'Id'. Other fields are treated as strings.
fix
If you need ObjectId conversion on custom fields, manually convert using $toObjectId aggregation or pre-process the data.
affects: >=1.0.0
gotchaThe node uses connection pooling by default; pools are managed globally. Do not manually close connections.
fix
Let n8n handle connection lifecycle. Avoid calling client.close() in workflow scripts.
affects: >=1.0.0
gotchaQuery and options parameters must be valid JSON strings. Invalid JSON will cause runtime errors.
fix
Use JSON.stringify() or ensure manual input is valid JSON.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'n8n-nodes-mongo'
Package not installed via n8n community node settings or npm path not configured.
fix
Install the node in n8n via Settings → Community Nodes → Install → n8n-nodes-mongo.
Unexpected token } in JSON at position 0
Query or options parameter is not valid JSON.
fix
Use JSON.stringify() to convert objects to JSON strings, e.g., '{"status":"active"}'.
MongoError: Authentication failed
Connection string or credentials are incorrect.
fix
Check the connection string (e.g., mongodb://user:pass@host:port/db) and ensure the database name is correct.
Cannot set property 'collection' of undefined
The node received invalid input or missing parameters, often because of incorrect output from previous node.
fix
Verify the node's input schema and ensure the collection name is provided as a string.
Upgrade
Version history
1.0.8latest on npm
Audit
Dependencies
n8n-workflowrequiredRequired for node execution in n8n environment
mongodbrequiredMongoDB driver used for database operations
Agent activity
4 hits · last 30 days
node
4
Resources
n8n-nodes-mongo — npm install n8n-nodes-mongo · libregistry