step
mongodb
Execute MongoDB database operations.
Overview
Supports operations:
- find: Query documents
- insert: Insert one or many documents
- update: Update documents matching filter
- delete: Delete documents matching filter
- aggregate: Run aggregation pipeline
- count: Count documents matching filter
Setup:
1. Create a MongoDB Atlas account at https://www.mongodb.com/cloud/atlas (or use self-hosted)
2. Create a cluster and database
3. Create a database user with appropriate permissions
4. Get your connection string from the Connect button in Atlas
5. Store your connection string securely (e.g., as an environment variable: MONGODB_URI)
Connection String: Required. Format: mongodb://username:password@host:port/database or mongodb+srv://...
- find: Query documents
- insert: Insert one or many documents
- update: Update documents matching filter
- delete: Delete documents matching filter
- aggregate: Run aggregation pipeline
- count: Count documents matching filter
Setup:
1. Create a MongoDB Atlas account at https://www.mongodb.com/cloud/atlas (or use self-hosted)
2. Create a cluster and database
3. Create a database user with appropriate permissions
4. Get your connection string from the Connect button in Atlas
5. Store your connection string securely (e.g., as an environment variable: MONGODB_URI)
Connection String: Required. Format: mongodb://username:password@host:port/database or mongodb+srv://...
Examples
Insert document
Insert a new document into a MongoDB collection
type: mongodb
connection_string: ${env:MONGODB_URI}
database: myapp
collection: users
operation: insert_one
document:
name: John Doe
email: john@example.com
created_at: 2024-01-15
output_to: insert_result
Find documents
Query documents from a collection with filter
type: mongodb
connection_string: ${env:MONGODB_URI}
database: myapp
collection: orders
operation: find
filter:
status: pending
amount:
$gt: 100
limit: 50
output_to: pending_orders
Update document
Update specific fields in a document
type: mongodb
connection_string: ${env:MONGODB_URI}
database: myapp
collection: users
operation: update_one
filter:
email: user@example.com
update:
$set:
last_login: 2024-01-15T10:30:00Z
status: active
output_to: update_result
Aggregation pipeline
Run complex aggregation queries
type: mongodb
connection_string: ${env:MONGODB_URI}
database: analytics
collection: events
operation: aggregate
pipeline:
- $match:
event_type: purchase
- $group:
_id: $user_id
total_spent:
$sum: $amount
output_to: user_spending
Configuration
| Parameter | Type | Required | Description |
|---|---|---|---|
type | string | No | Step type identifier
Default: "mongodb" |
connection_string | string | No | MongoDB connection string (mongodb:// or mongodb+srv://). Takes precedence over host/port/username/password if provided |
host | string | No | MongoDB host address (alternative to connection_string) |
port | integer | No | MongoDB port number
Default: 27017 |
username | string | No | MongoDB username for authentication |
password | string | No | MongoDB password for authentication |
database | string | Yes | Name of the MongoDB database to use |
collection | string | Yes | Name of the collection (table) to operate on |
operation | string | Yes | MongoDB operation to perform: find (query), insert (add documents), update (modify), delete (remove), aggregate (pipeline), or count (total)
Options: find, insert, update, delete, aggregate, count |
filter | string | No | Query filter for find, update, delete, or count operations (MongoDB query syntax) |
document | string | No | Single document to insert (for insert operation) |
documents | string | No | Multiple documents to insert in bulk (for insert operation) |
update | string | No | Update operations to apply (for update operation, MongoDB update syntax) |
pipeline | string | No | Aggregation pipeline stages (for aggregate operation) |
projection | string | No | Fields to include or exclude in query results (1 = include, 0 = exclude) |
sort | string | No | Sort specification as list of (field, direction) tuples (1 = ascending, -1 = descending) |
limit | integer | No | Maximum number of documents to return (for find operation)
Default: 1000 |
skip | integer | No | Number of documents to skip (for pagination in find operation)
Default: 0 |
upsert | boolean | No | If True, insert document if no match is found (for update operation)
Default: false |
timeout | integer | No | Connection timeout in seconds
Default: 30 |
output_to | string | No | Key name where results will be stored in the event
Default: "mongodb" |
Base Configuration
These configuration options are available on all steps:
| Parameter | Type | Default | Description |
|---|---|---|---|
name | | null | Optional name for this step (for documentation and debugging) |
description | | null | Optional description of what this step does |
retries | integer | 0 | Number of retry attempts (0-10) |
backoff_seconds | number | 0 | Backoff (seconds) applied between retry attempts |
retry_propagate | boolean | false | If True, raise last exception after exhausting retries; otherwise swallow. |