Actions11
Overview
This node enables interaction with MongoDB databases, specifically allowing users to insert documents into a specified collection. It is useful in scenarios where you want to programmatically add new records to a MongoDB collection from workflows, such as logging events, adding user data, or storing form submissions.
For example, you might use this node to insert customer information collected from a web form into a "customers" collection, or to log sensor data into a "readings" collection for later analysis.
Properties
| Name | Meaning |
|---|---|
| Collection | The name of the MongoDB collection where the new document(s) will be inserted. |
| Fields | Comma-separated list of fields to include in the new document(s). |
| Options | Additional options for insertion: |
| Date Fields | Comma-separated list of fields that should be parsed as MongoDB Date type. |
| Use Dot Notation | Boolean flag indicating whether to use dot notation to access date fields (true/false). |
Output
The output consists of an array of JSON objects representing the inserted documents. Each output item corresponds to one inserted document and includes all fields provided plus an id field containing the MongoDB-generated identifier for that document.
Example output item:
{
"field1": "value1",
"field2": "value2",
"id": "60d5ec49f8d2e30b8c123456"
}
No binary data is produced by this operation.
Dependencies
- Requires a MongoDB database connection configured via credentials that provide necessary authentication (such as an API key or connection string).
- The node uses the official MongoDB Node.js driver to connect and perform operations.
- The workflow environment must have network access to the MongoDB instance.
Troubleshooting
Common issues:
- Incorrect collection name or database name can cause errors like "collection does not exist".
- Invalid field names or malformed JSON in input properties may cause parsing errors.
- Network connectivity problems or invalid credentials will prevent connection to MongoDB.
- If date fields are incorrectly specified, dates may not be stored properly.
Error messages:
"Database \"<name>\" does not exist": Verify the database name in credentials."error": "<message>"in output: Indicates an error occurred during insertion for that item. Check the message for details.- Connection errors: Ensure credentials and network access are correct.
Resolution tips:
- Double-check collection and database names.
- Validate JSON syntax in fields and options.
- Confirm that date fields are correctly named and formatted.
- Test credentials separately to ensure connectivity.