What it is for
The MongoDB component connects flooows to your document database to find, insert, update, replace, delete and aggregate data. Use it to store events from other apps, enrich records or build reports with aggregation pipelines.
MongoDB has no triggers: it is used as an action inside flows started by other triggers.
Set up the connection
Authentication type: Custom credentials
- 1Gather your MongoDB server or Atlas cluster details and create a database user with the required permissions.
- 2If you use Atlas, add the appropriate network access in the cluster's IP access list.
- 3In flooows add a MongoDB step and click "Connect".
- 4Fill in Host, tick Use MongoDB Atlas URL Format for an Atlas cluster, and provide Database, Username, Password and, if needed, Auth Source (usually admin).
- 5Save the connection.
| Connection field | Type | Required |
|---|---|---|
| Host | Text | Yes |
| Use MongoDB Atlas URL Format | Yes / No | Yes |
| Database | Text | No |
| Username | Text | Yes |
| Password | Secret key | Yes |
| Auth Source | Text | No |
Credentials are stored encrypted in your isolated database, in Spain, and are never shown in plain text.
How to use it in a flow
- Insert Documents: pick the Collection and pass an object or list in JSON in Documents, mapping fields from earlier steps.
- Find Documents: write a JSON Query, for example {"email": "..."}, and use Projection, Sort, Limit and Skip to shape the result.
- Update Documents: set the Filter and the Update using operators such as $set; enable Upsert to create the document if missing.
- Aggregate Documents: enter an Aggregation Pipeline in JSON to group or compute totals.
Tips
- •Test filters in MongoDB Compass before using them in the flow.
- •Find and Update Documents with Return Updated Documents gives you the modified result.
- •Leave Database empty in the action to use the connection's database.
Actions (7)
Operations available as flow steps. Expand each one to see its fields.
Find Documents7 fields
| Field | Type | Required |
|---|---|---|
| Database | Text | No |
| Collection | List (from your account) | Yes |
| Query | JSON | No |
| Projection | JSON | No |
| Sort | JSON | No |
| Limit | Number | No |
| Skip | Number | No |
Insert Documents3 fields
| Field | Type | Required |
|---|---|---|
| Database | Text | No |
| Collection | List (from your account) | Yes |
| Documents | JSON | Yes |
Update Documents5 fields
| Field | Type | Required |
|---|---|---|
| Database | Text | No |
| Collection | List (from your account) | Yes |
| Filter | JSON | Yes |
| Update | JSON | Yes |
| Upsert | Yes / No | No |
Delete Documents3 fields
| Field | Type | Required |
|---|---|---|
| Database | Text | No |
| Collection | List (from your account) | Yes |
| Filter | JSON | Yes |
Find and Update Documents6 fields
| Field | Type | Required |
|---|---|---|
| Database | Text | No |
| Collection | List (from your account) | Yes |
| Filter | JSON | Yes |
| Update | JSON | Yes |
| Upsert | Yes / No | No |
| Return Updated Documents | Yes / No | No |
Find and Replace Documents6 fields
| Field | Type | Required |
|---|---|---|
| Database | Text | No |
| Collection | List (from your account) | Yes |
| Filter | JSON | Yes |
| Replacement Document | JSON | Yes |
| Upsert | Yes / No | No |
| Return Document | Fixed list | No |
Aggregate Documents3 fields
| Field | Type | Required |
|---|---|---|
| Database | Text | No |
| Collection | List (from your account) | Yes |
| Aggregation Pipeline | JSON | Yes |
Common errors
Authentication failed.
Check username, password and Auth Source.
Connection timeout.
Check the Host and the Atlas IP access list.
Invalid JSON.
Validate the syntax of Query, Filter or Update; keys must use double quotes.
Field types
"List (from your account)" loads options from your connected account; "Dynamic fields" appear depending on earlier choices; in any field you can insert data from previous steps with the data selector (e.g. {{trigger.email}}). More about data between steps
