Reference · Tools

MongoDB

Find, insert, update, replace, delete, and aggregate documents in MongoDB. Manage Atlas Search indexes.

Action Data & Storage v1

The MongoDB node performs document CRUD and aggregation — find, insert, update, replace, delete and aggregate — and can manage Atlas Search indexes. A typical build is aggregating yesterday's events into a summary collection each morning.

Node type
Action
Parameters
21
Outputs
Output, Error
Credentials
MongoDB

MongoDB

Find, insert, update, and delete documents in MongoDB

Overview

Runs CRUD operations against documents in a MongoDB database: find (with filter, sort, projection, skip and limit), insert (single or batch), update (one $set update per item), find-and-update, find-and-replace, delete (deletes every match), and aggregation pipelines. It also manages Atlas Search indexes — create, list, update and drop. The node connects with the official MongoDB Node.js driver and accepts either a full connection string or host/port credentials.

Category: Data & Storage
Tool Name: mongodb
Version: 1

Appearance: Icon: si-mongodb | Color: #13AA52

Node Type

Action — processes input items and produces output

Input / Output

DirectionPort(s)
InputInput
OutputOutput, Error

Credentials

This tool requires MongoDB credentials. See the Credentials Guide for setup instructions.

Resources

ResourceValue
Documentdocument
Search IndexsearchIndexes

Operations

OperationValueDescription
AggregateaggregateRun an aggregation pipeline
DeletedeleteDelete documents matching a filter
FindfindFind documents matching a query
Find And ReplacefindOneAndReplaceFind a document and replace it entirely
Find And UpdatefindOneAndUpdateFind a document and update specific fields using $set
InsertinsertInsert new documents
UpdateupdateUpdate documents using updateOne per item
CreatecreateSearchIndexCreate an Atlas Search index
DropdropSearchIndexDrop an Atlas Search index
ListlistSearchIndexesList Atlas Search indexes
UpdateupdateSearchIndexUpdate an Atlas Search index definition

The first seven belong to the Document resource; the last four belong to Search Index.

Parameters

Document: Aggregate

ParameterTypeRequiredDefaultDescription
Query (JSON)jsonYesMongoDB aggregation pipeline as a JSON array of stage objects.
Allow UnboundedbooleanNofalseAllow unbounded queries (no row cap). Use with extreme caution — can OOM the worker.

Document: Delete

ParameterTypeRequiredDefaultDescription
Delete Query (JSON)jsonYes{}MongoDB delete filter as a JSON object. All matching documents will be deleted (deleteMany).
Confirm Delete AllbooleanNofalseRequired when the delete filter is empty (matches every document). Safety guard against accidental wipe.

Document: Find

ParameterTypeRequiredDefaultDescription
Query (JSON)jsonYes{}MongoDB find filter as a JSON object.
OptionscollectionNo{}Additional query options for find.
— LimitnumberNo0Maximum number of documents to return. 0 = unlimited.
— SkipnumberNo0Number of documents to skip in the result set.
— Sort (JSON)jsonNo{}Sort order as a JSON object. Use 1 for ascending, -1 for descending.
— Projection (JSON)jsonNo{}Fields to include or exclude in results. 1 = include, 0 = exclude.
Allow UnboundedbooleanNofalseAllow unbounded queries (no row cap). Use with extreme caution — can OOM the worker.

Document: Insert

ParameterTypeRequiredDefaultDescription
FieldsstringNoComma-separated list of fields from input items to include in the inserted documents. Leave empty to include all fields.
OptionscollectionNo{}Additional options for insert/update/replace operations.
— Date FieldsstringNoComma-separated list of fields to parse as MongoDB Date type.
— Use Dot NotationbooleanNofalseWhether to use dot notation to access nested fields. E.g. “address.city” resolves to { address: { city: value } }.

Document: Update

ParameterTypeRequiredDefaultDescription
Update KeystringYes_idField name used to match the document to update. Use “_id” for the MongoDB document ID.
FieldsstringNoComma-separated list of fields to include in the update/replacement document.
UpsertbooleanNofalseWhether to insert a new document if no documents match the update key.
OptionscollectionNo{}Additional options for insert/update/replace operations.
— Date FieldsstringNoComma-separated list of fields to parse as MongoDB Date type.
— Use Dot NotationbooleanNofalseWhether to use dot notation to access nested fields. E.g. “address.city” resolves to { address: { city: value } }.

Document: Find And Update

ParameterTypeRequiredDefaultDescription
Update KeystringYes_idField name used to match the document to update. Use “_id” for the MongoDB document ID.
FieldsstringNoComma-separated list of fields to include in the update/replacement document.
UpsertbooleanNofalseWhether to insert a new document if no documents match the update key.
OptionscollectionNo{}Additional options for insert/update/replace operations.
— Date FieldsstringNoComma-separated list of fields to parse as MongoDB Date type.
— Use Dot NotationbooleanNofalseWhether to use dot notation to access nested fields. E.g. “address.city” resolves to { address: { city: value } }.

Document: Find And Replace

ParameterTypeRequiredDefaultDescription
Update KeystringYes_idField name used to match the document to update. Use “_id” for the MongoDB document ID.
FieldsstringNoComma-separated list of fields to include in the update/replacement document.
UpsertbooleanNofalseWhether to insert a new document if no documents match the update key.
OptionscollectionNo{}Additional options for insert/update/replace operations.
— Date FieldsstringNoComma-separated list of fields to parse as MongoDB Date type.
— Use Dot NotationbooleanNofalseWhether to use dot notation to access nested fields. E.g. “address.city” resolves to { address: { city: value } }.

Document: All Operations

ParameterTypeRequiredDefaultDescription
ObjectId FieldsstringNo_idComma-separated list of field names whose string values should be coerced to ObjectId (e.g. “_id,userId,orderId”).

Search Index: Create

ParameterTypeRequiredDefaultDescription
Index Name (indexNameRequired)stringYesThe name of the search index.
Index Definition (JSON)jsonYes{}The search index definition as a JSON object.
Index TypeoptionsYesvectorSearchThe type of search index to create.
Options: vectorSearch, search

Search Index: Update

ParameterTypeRequiredDefaultDescription
Index Name (indexNameRequired)stringYesThe name of the search index.
Index Definition (JSON)jsonYes{}The search index definition as a JSON object.

Search Index: Drop

ParameterTypeRequiredDefaultDescription
Index Name (indexNameRequired)stringYesThe name of the search index.

Search Index: List

ParameterTypeRequiredDefaultDescription
Index Name (indexName)stringNoIf provided, only lists indexes matching this name.

All Operations

ParameterTypeRequiredDefaultDescription
CollectionstringYesThe MongoDB collection name. Supports expressions.
Max ConcurrencynumberNo10Maximum number of items to process concurrently.

Output Data

The result replaces the item’s JSON — the incoming fields do not pass through — while binary data on the input item is forwarded. ObjectId values in results are converted to strings so they survive JSON serialization.

OperationOutput
findOne item per matching document.
aggregateOne item per pipeline result document.
insertOne item — the document as inserted, with _id added as a string.
updateOne item carrying the fields that were written.
findOneAndUpdateOne item — the document as it stands after the update.
findOneAndReplaceOne item — the document as it stands after the replacement.
deleteOne item carrying deletedCount.
listSearchIndexesOne item per index, carrying that index’s definition as Atlas reports it.
createSearchIndexOne item carrying indexName.
dropSearchIndex, updateSearchIndexOne item carrying the index name as a key set to true.

An operation that matches nothing still emits one item, with empty JSON, so the branch does not go silent.

A found document looks like the stored document itself:

{
  "_id": "6520f1c3a4e5b6c7d8e9f012",
  "name": "Ada Lovelace",
  "email": "ada@example.com",
  "status": "active"
}

Usage Examples

  • Find all active users in MongoDB
  • Insert a new document into a collection
  • Update documents matching a filter with $set
  • Delete documents matching a query
  • Run an aggregation pipeline
  • Create an Atlas vector search index

Example Configuration

Find documents with a filter, sort and projection:

{
  "type": "mongodb",
  "parameters": {
    "resource": "document",
    "operation": "find",
    "collection": "users",
    "query": "{\"status\": \"active\", \"age\": {\"$gte\": 18}}",
    "options": {
      "limit": 100,
      "skip": 0,
      "sort": "{\"createdAt\": -1}",
      "projection": "{\"name\": 1, \"email\": 1, \"status\": 1}"
    }
  }
}

Insert selected fields of each incoming item:

{
  "type": "mongodb",
  "parameters": {
    "resource": "document",
    "operation": "insert",
    "collection": "products",
    "fields": "name,price,category,description",
    "options": {
      "dateFields": "createdAt,updatedAt",
      "useDotNotation": false
    },
    "maxConcurrency": 5
  }
}

Update a document matched on a business key:

{
  "type": "mongodb",
  "parameters": {
    "resource": "document",
    "operation": "update",
    "collection": "orders",
    "updateKey": "orderId",
    "fields": "status,updatedAt,notes",
    "upsert": false,
    "options": {
      "dateFields": "updatedAt",
      "useDotNotation": true
    }
  }
}

Run an aggregation pipeline:

{
  "type": "mongodb",
  "parameters": {
    "resource": "document",
    "operation": "aggregate",
    "collection": "sales",
    "query": "[{\"$match\": {\"date\": {\"$gte\": \"2024-01-01\"}}}, {\"$group\": {\"_id\": \"$category\", \"total\": {\"$sum\": \"$amount\"}}}, {\"$sort\": {\"total\": -1}}]"
  }
}

Delete old records:

{
  "type": "mongodb",
  "parameters": {
    "resource": "document",
    "operation": "delete",
    "collection": "logs",
    "query": "{\"createdAt\": {\"$lt\": \"2024-01-01\"}, \"level\": \"debug\"}"
  }
}

Replace a whole document, creating it if it is missing:

{
  "type": "mongodb",
  "parameters": {
    "resource": "document",
    "operation": "findOneAndReplace",
    "collection": "configurations",
    "updateKey": "configId",
    "fields": "settings,version,updatedBy",
    "upsert": true,
    "options": {
      "dateFields": "updatedAt",
      "useDotNotation": false
    },
    "maxConcurrency": 1
  }
}

Update a document and read back the result:

{
  "type": "mongodb",
  "parameters": {
    "resource": "document",
    "operation": "findOneAndUpdate",
    "collection": "inventory",
    "updateKey": "sku",
    "fields": "quantity,lastRestocked,location",
    "upsert": true,
    "options": {
      "dateFields": "lastRestocked",
      "useDotNotation": false
    }
  }
}

Create an Atlas text search index:

{
  "type": "mongodb",
  "parameters": {
    "resource": "searchIndexes",
    "operation": "createSearchIndex",
    "collection": "articles",
    "indexNameRequired": "article_search",
    "indexType": "search",
    "indexDefinition": "{\"mappings\": {\"dynamic\": false, \"fields\": {\"title\": {\"type\": \"string\"}, \"content\": {\"type\": \"string\"}, \"tags\": {\"type\": \"stringFacet\"}}}}"
  }
}

Create an Atlas vector search index:

{
  "type": "mongodb",
  "parameters": {
    "resource": "searchIndexes",
    "operation": "createSearchIndex",
    "collection": "embeddings",
    "indexNameRequired": "vector_index",
    "indexType": "vectorSearch",
    "indexDefinition": "{\"fields\": [{\"type\": \"vector\", \"path\": \"embedding\", \"numDimensions\": 768, \"similarity\": \"cosine\"}]}"
  }
}

List the search indexes on a collection:

{
  "type": "mongodb",
  "parameters": {
    "resource": "searchIndexes",
    "operation": "listSearchIndexes",
    "collection": "products",
    "indexName": "product_search"
  }
}

Drop a search index:

{
  "type": "mongodb",
  "parameters": {
    "resource": "searchIndexes",
    "operation": "dropSearchIndex",
    "collection": "old_data",
    "indexNameRequired": "deprecated_index"
  }
}

Error Handling

ModeBehavior
stopHalts workflow on first error
continueSkips failed items, passes successful ones through
errorPortRoutes failed items to Error output port

Tips

Perform CRUD operations on MongoDB documents: find, insert, update, replace, delete, aggregate, and manage Atlas Search indexes.

  • Reads are capped at 10,000 documents unless you turn on Allow Unbounded. A Limit of 0 inside Find’s Options means “no limit”, which is still subject to that cap until the guard is lifted. Turning it off is a deliberate choice — an unbounded read of a large collection can exhaust the worker’s memory.
  • Long-running queries are cut off. A find, aggregate or write that has not returned within 30 seconds is abandoned and the item fails.
  • Deleting with an empty filter is refused unless Confirm Delete All is on, because an empty filter matches every document in the collection.
  • Server-side JavaScript is blocked. Filters and pipelines containing $where, $function, $accumulator or $accumulatorJs are rejected before they reach the database.
  • String IDs become ObjectIds automatically. By default only _id is coerced; add more field names to ObjectId Fields when your filters reference other reference columns. A value that is not a valid ObjectId is left as a string, so legacy string IDs still match.
  • Fields is mandatory for the three write-by-key operations. Update, Find And Update and Find And Replace each need a comma-separated field list; the Update Key is added to that list automatically.
  • Use Dot Notation reads nested values. With it on, a field named address.city is pulled out of the nested item structure — for updates the key stays flat so it becomes a targeted $set on that path.
  • Find, Aggregate and List fan out — every returned document becomes its own item.

Frequently asked questions

Why is my query returning only 10,000 documents?

Reads are capped at 10,000 unless Allow Unbounded is turned on. A Limit of 0 inside Find's Options means no limit, but it is still subject to that cap until the guard is lifted.

Should I turn off the read cap?

Only deliberately. An unbounded read of a large collection can exhaust the worker's memory, which is exactly what the guard exists to prevent.

What happens to a slow query?

Long-running finds, aggregates and writes are cut off rather than left to run indefinitely, so a pathological query cannot hold a worker open.

Can it manage Atlas Search?

Yes — Atlas Search index management is supported alongside the document operations.

Build with the MongoDB node

Drop it into a workflow, wire it to an agent, or call it on a schedule. You'll need MongoDB credentials first.

Open BusyBot

Last updated . Spotted something wrong? Tell us.