- Home
- Resources
- Integrations
- MongoDB
MongoDB n8n integrationAutomate MongoDB with n8n.
Every document a workflow touches can live in a MongoDB collection. The MongoDB n8n integration exposes 11 operations across 2 resources: documents are found, inserted, updated, replaced, deleted or aggregated, and search indexes handled from the same node. No trigger ships with it: the workflow starts elsewhere.
Verified Trustpilot reviews · AI, automation & growth agency
What does the MongoDB n8n integration actually do?
The MongoDB node connects an n8n workflow to a MongoDB database and runs queries against it. Eleven operations sit under 2 resources: Document, where data is read and written, and Search Index, where the indexes that make a collection searchable are created, listed, updated and dropped. Queries are written in JSON, the same JSON you would hand to the database itself, so nothing is hidden behind a simplified form.
The first shape of workflow treats MongoDB as the place where everything lands. A scraping branch walks through a list of pages, an HTTP Request node brings back the content, and document.insert writes one document per page. Teams that also keep a copy in Google Sheets usually leave the sheet for people to read and the collection for volume, because a sheet gets slow long before a collection does.
The second reads rather than writes. A Schedule Trigger wakes the workflow, document.find pulls the documents matching a query, and the result goes out as a message in Slack or as a row in a report. When the workflow only needs a count or a grouped total, document.aggregate pushes that work into the database and returns the result already computed, which keeps the execution small.
The third keeps two systems aligned. An incoming payload carries an identifier, document.findOneAndUpdate writes the new values onto the matching document, and Upsert creates it when nothing matches. The pattern is the same one used with the Postgres and MySQL nodes, except the target is a document instead of a row, so a field that did not exist yesterday does not need a migration today.
Two limits are worth knowing before building. MongoDB has no trigger node in n8n, so nothing reacts to a document changing on its own: a Schedule Trigger at a fixed interval, or a Webhook called by whatever writes the data, has to open the workflow. And every filter is hand written JSON, so a wrong operator returns an empty list instead of an error. Run the query through Find documents before wiring it into Delete documents.
So where does the HTTP Request node fit? Its usual job is calling an API endpoint that a dedicated node leaves out, reusing the same credential. Here the credential opens a MongoDB connection string rather than an API key, so there is no endpoint for HTTP Request to call: the escape hatch is Find documents and Aggregate documents instead, since both take a hand written JSON query or pipeline. Everything outside the 11 operations goes through one of those two. The choice between self hosting and the hosted plan, on the other hand, is covered in the n8n review.
What does n8n need to reach the database?
- 01
Create a database user for the workflow
A workflow connects to MongoDB as a database user, never as your own console account. Create one on the server with the permissions the workflow actually needs: read only if the branch stops at Find documents, read and write as soon as Insert documents, Update documents or Delete documents appear. Keep the user name and the password aside, both go into the credential in a minute.
- 02
Open the network to n8n
A cluster answers only the addresses it knows. As a Project Owner, open Network Access in the project and add the n8n IP addresses to the IP Access List Entries. Skip that step and the connection never gets as far as the query: the credential can be perfect and the database still refuses the caller. The entries sit at project level, so one list covers every workflow pointing at this cluster.
- 03
Fill the MongoDB credential
In the Credentials menu, create a MongoDB credential and pick a Configuration Type. Connection String takes the string found under Database then Connect then Drivers, shaped like
mongodb+srv://user:password@cluster.mongodb.net/with the placeholders replaced by the real user and password, plus the Database name. Values asks for the same facts one field at a time: Host, Database, User, Password and Port.
What the MongoDB node does, operation by operation
The MongoDB node exposes 11 operations across 2 resources. For each one: the node as you configure it in n8n, the required fields, and our field notes.
| Resource | Update | Delete | Aggregate | Create | Drop | Find | Find And Replace | Find And Update | Insert | List | Update |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Search Index | ✓ | ✓ | ✓ | ✓ | |||||||
| Document | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Operations index
Search Index
4 operationsCreate Search Index
searchIndexes.createSearchIndexWhat you see in n8n
Notes & use cases
Adds a search index to a collection so its content becomes searchable. The shape of the index comes from a JSON definition, not from a form.
Key parameters
- Collection: the collection the index is built on, spelled as it is in the database.
- Index Name: the name of the index, reused by every later operation.
- Index Type: two values only,
vectorSearchorsearch. - Index Definition: the definition in JSON, on the model shown in the field placeholder,
{ "type": "vectorSearch", "definition": {} }.
Drop Search Index
searchIndexes.dropSearchIndexWhat you see in n8n
Notes & use cases
Removes a search index from a collection. The documents stay where they are, only the index disappears, and the node needs nothing more than two names to do it.
Key parameters
- Collection: the collection the index currently belongs to.
- Index Name: the exact name the index was created with, since this operation offers no list to pick from.
List Search Indexes
searchIndexes.listSearchIndexesWhat you see in n8n
Notes & use cases
Returns the search indexes defined on a collection. It is the read only operation of the resource, and the one to call when the workflow has to decide what to do next.
Key parameters
- Collection: the collection whose indexes are listed.
- Index Name: optional, and it changes the nature of the call. Filled in, only indexes carrying that name come back, which turns the operation into an existence check.
Update Search Index
searchIndexes.updateSearchIndexWhat you see in n8n
Notes & use cases
Sends a new definition to a search index that already exists. Note what is missing compared to the creation: there is no Index Type here, the type stays the one chosen at the start.
Key parameters
- Collection: the collection holding the index.
- Index Name: the index that receives the new definition.
- Index Definition: the full JSON definition, in the same format as at creation, placeholder included in the field.
Document
7 operationsAggregate documents
document.aggregateWhat you see in n8n
Notes & use cases
Runs an aggregation pipeline on a collection and returns its output. The calculation happens inside the database, the workflow only receives the result.
Key parameters
- Collection: the collection the pipeline reads from.
- Query: the pipeline itself, a JSON array of stages, on the model of the placeholder
[{ "$match": { "$gt": "1950-01-01" }, ... }]. An expression such as{{ $json.since }}drops a value from the previous node straight into a stage.
Delete documents
document.deleteWhat you see in n8n
Notes & use cases
Deletes the documents that match a filter. The operation takes nothing but a collection and a query, so the query is the only safeguard between the workflow and the data.
Key parameters
- Collection: where the deletion runs.
- Delete Query (JSON Format): the Mongo filter, shaped like the placeholder
{ "birth": { "$gt": "1950-01-01" } }. Run the same filter through Find documents first and count what comes back.
Find documents
document.findWhat you see in n8n
Notes & use cases
Reads the documents matching a query and passes them on. It opens most MongoDB branches, since nothing in n8n reacts to the database on its own.
Key parameters
- Query (JSON Format): the Mongo filter, on the model of
{ "birth": { "$gt": "1950-01-01" } }. - Limit: the maximum number of documents returned,
0meaning no ceiling at all. - Skip: how many documents to step over, the companion of Limit on a long collection.
- Sort (JSON Format): the order of the result set, written as
{ "field": -1 }for a descending sort. - Projection (JSON Format): the fields to keep or drop,
{ "_id": 0, "field": 1 }, which keeps the payload light.
Find and replace documents
document.findOneAndReplaceWhat you see in n8n
Notes & use cases
Looks for the document designated by the update key and swaps it for a new one, built from the fields listed in the operation.
Key parameters
- Update Key: the property that decides which document is concerned, usually
id, and it has to exist on the incoming item too. - Fields: the comma separated list of fields that go into the new document, in the form
name,description. - Upsert: on, a document is inserted when the update key matches nothing.
Find and update documents
document.findOneAndUpdateWhat you see in n8n
Notes & use cases
Finds the document that carries the update key and writes the listed fields onto it. Same two required fields as Find and replace documents, a different intention: here the document is kept and modified.
Key parameters
- Update Key: the property used to recognize the document,
idin most collections. - Fields: the fields to write, comma separated, in the same
name,descriptionform. - Date Fields: the fields to read as a Mongo Date rather than as text, which matters as soon as a date is compared later.
Insert documents
document.insertWhat you see in n8n
Notes & use cases
Writes the incoming items into a collection as new documents. There is no update key on this operation, so nothing is looked up before the write.
Key parameters
- Collection: the collection that receives the documents.
- Fields: the comma separated list of fields included in the new document,
name,description. Only what is named here lands in MongoDB. - Use Dot Notation: on when a date sits inside a nested object and has to be reached through a path.
Update documents
document.updateWhat you see in n8n
Notes & use cases
Applies the listed fields to the documents identified by the update key. The bulk cousin of the find and update operation, aimed at a batch of items arriving together.
Key parameters
- Collection: the collection where the update lands.
- Update Key: the property that decides which documents change,
idby convention. - Upsert: without it, an item that matches no document produces no insert at all.
Need help automating MongoDB with n8n?
A person reads every message.
