MongoDB
Perform database operations on your MongoDB collections without writing code.
The MongoDB block allows you to interact with your MongoDB database collections. You can find, insert, update, or delete documents using a visual builder or raw JSON queries.
Core Concept
Think of a MongoDB collection as a folder full of flexible documents. This block lets you "search" the folder for specific documents, "add" new ones, or "change" what's inside them without needing to write complex database drivers.
Configuration
| Field | Required | Description |
|---|---|---|
| Connection | ✅ | Select your pre-configured MongoDB database connection from the list. |
| Collection Name | ✅ | The name of the collection you want to interact with (e.g., users or orders). |
| Operation | ✅ | Choose the action to perform: Find One, Find Many, Insert One, Update One, Update Many, Delete One, Delete Many, or Count. |
| Filter Mode | — | Choose Simple Builder for no-code filtering or Advanced to provide a raw MongoDB query object. |
| Filter Conditions | — | (Simple Mode) Define rules to find documents (e.g., email equals {request.body.email}). |
| Query JSON | — | (Advanced Mode) Provide a raw MongoDB query (e.g., { "status": "active", "age": { "$gt": 18 } }). |
| Data Mode | — | Choose Simple Builder for key-value entry or Advanced for raw JSON data. |
| Fields to Set | — | (Simple Mode) Define the fields and values to insert or update. You can force specific data types like String, Number, or Boolean. |
| Data JSON | — | (Advanced Mode) Provide the raw document or update operators (e.g., { "$set": { "verified": true } }). |
| Output Variable | ✅ | The variable where the operation result (document, list, or status) will be stored. |
When filtering by MongoDB _id, ensure you are using the correct format. If your collection uses standard ObjectIDs, you may need to use the Advanced mode to wrap the ID string.
Variable Syntax Rules
- Single braces only:
{variable_name}. - Library variables:
{MY_VAR}. - Request data:
{request.body.field}or{request.query.field}. - Never use
{{double_braces}}.
Error Handling
FIELD_MISSING— Triggered when required fields like Connection or Collection Name are empty.CONNECTION_FAILED— Triggered if the block cannot connect to your MongoDB server.OPERATION_FAILED— Triggered if the database rejects the query (e.g., invalid JSON or permissions).SECRET_ERROR— Triggered if the stored connection credentials cannot be retrieved.
Example
- Setup: Select your "Production DB" connection and set the collection to
users. - Operation: Set Operation to
Find One. - Filter: Add a condition where
emailequals{request.body.email}. - Variable: Set Output Variable to
user_data.
Result: After execution, {user_data} will contain the document found in the database. You can then access fields like {user_data.username} in later blocks.
