MongoDB CRUD Operations

This workflow automates MongoDB CRUD operations via a webhook, performing insert, find, update, and delete actions. Key nodes include Webhook (receives POST requests), Input Validation (sanitizes inputs), Check Input Valid (verifies operation), Prepare Insert/Update Data (formats documents), MongoDB Insert/Find/Update/Delete (executes queries), Check Insert Success (confirms insertion), Process Operations Result (summarizes output), Success Response (returns JSON), and error responses (Invalid Input, Insert Error, MongoDB Operations). It uses the MongoDB service. Setup Requirements Install n8n from n8n.io or sign up at cloud.n8n.io. Import the JSON into n8n’s workflow editor. Install MongoDB locally or use a cloud provider (e.g., MongoDB Atlas). Obtain MongoDB credentials (connection string, database name, username, password) from your MongoDB instance or provider’s dashboard. In n8n, configure MongoDB credentials under mongodb-credentials with the connection string (e.g., mongodb+srv://user:pass@cluster.mongodb.net/db), database name, and authentication details. Configure the Webhook node by copying its URL (/mongodb-operations). Set allowedOrigins (e.g., 'https://your-domain.com') for security. The workflow expects a JSON payload with 'operation' (e.g., test_crud), 'collection', 'name', 'id', and 'data'. Handle errors like invalid operation (400: Invalid operation) or connection failure (502: Failed to insert). Secure credentials and webhook URL. Testing and Deployment Import the JSON into n8n and activate the workflow. Ensure MongoDB is running and credentials are configured. Test the Webhook with a POST request (e.g., curl -X POST [webhook-url] -d '{"operation": "test_crud", "collection": "testcollection", "name": "TestDoc"}' -H 'Content-Type: application/json'). Verify MongoDB Insert/Find/Update queries execute, Delete removes the document, and Success Response returns JSON with operation summaries. Test error cases: invalid operation (400: Invalid operation), wrong credentials (502: Failed to connect), or non-existent collection (502: MongoDB operations failed). Check n8n and MongoDB logs for errors. Integrate the webhook URL into your application, ensure MongoDB accessibility, activate the workflow, and deploy for automated operations. Monitor MongoDB connection stability and query performance.

$6.99

Workflow steps: 15

Integrated apps: webhook, set, if

MongoDB CRUD Operations preview