Delete One
AI-generatedOverview
This node performs various MongoDB operations on specified collections within a database. It connects to a MongoDB instance using provided credentials and executes commands such as updating documents, finding documents, aggregating data, inserting new documents, replacing existing documents, or deleting documents.
The "Delete One" operation specifically deletes a single document from a given collection that matches the provided query criteria.
Common scenarios:
- Removing outdated or unwanted records from a MongoDB collection based on specific conditions.
- Cleaning up test or temporary data after processing.
- Managing data lifecycle by deleting entries that meet certain criteria.
Example:
You have a collection of user profiles and want to delete one profile where the user's email matches a particular address. You would specify the collection name and provide a JSON query with the email condition to delete that single matching document.
Properties
| Name | Meaning |
|---|---|
| Collection | The name of the MongoDB collection where the operation will be performed. |
| Query (JSON Format) | A JSON-formatted MongoDB query object specifying the filter criteria for the operation. For "Delete One", it defines which document to delete. Example: { "status": "inactive" } |
Output
The output is an array of JSON objects representing the input items passed through the node after the deletion operation has been executed. Since the "Delete One" operation does not return the deleted document, the output essentially confirms the operation was performed on each input item.
If an error occurs during execution and the node is configured to continue on failure, the output will contain an object with an error property describing the issue.
No binary data is output by this node.
Dependencies
- Requires a valid connection to a MongoDB database, including:
- A connection string or equivalent credentials to authenticate and connect.
- Access rights to perform delete operations on the specified collection.
- The node depends on the MongoDB Node.js driver internally to execute commands.
- Proper configuration of the MongoDB credentials in n8n is necessary before use.
Troubleshooting
Common issues:
- Invalid or malformed JSON in the "Query" property can cause parsing errors.
- Insufficient permissions on the MongoDB user may result in authorization errors when attempting to delete documents.
- Incorrect collection names or database names will lead to runtime errors indicating the collection does not exist.
- Network connectivity problems to the MongoDB server can cause connection failures.
Error messages:
"SyntaxError: Unexpected token ..."— Indicates invalid JSON format in the query; verify and correct the JSON syntax."MongoError: not authorized"— The credentials used do not have permission to delete documents; check user roles and privileges."MongoNetworkError"— Connection to MongoDB failed; ensure the connection string and network access are correct.
To handle errors gracefully, enable the "Continue On Fail" option in the node settings, which allows the workflow to proceed even if some deletions fail.