Portal Community

When to Use

Configuration

Connection

FieldRequiredDescription
ConnectionUriRequiredMongoDB connection string. Example: mongodb+srv://appuser:s3cr3t@cluster0.abc12.mongodb.net/. Always reference a stored credential: {{ $credentials.mongodbAtlas }}.
DatabaseRequiredThe database name to write into. Example: ecommerce, hrcore, analytics.
CollectionRequiredThe collection name. Example: orders, employees, audit_logs. Created automatically if it does not exist.

Operation

FieldRequiredDescription
DocumentsRequiredArray of document objects to insert. Each element is a plain JSON object representing one document. Minimum one document required. Example: [{"orderId":"ORD-001","customerId":"C-42","total":149.99}]. Supports expressions: {{ $json.documentsArray }}.
OrderedOptionalDefault true. When true, MongoDB stops inserting on the first error and reports the failure. When false, MongoDB continues inserting remaining documents despite individual failures — ideal for bulk ingestion where partial success is acceptable. Use false for parallel or idempotent batch inserts.

Sample Configuration

Bulk insert of customer order records from a webhook payload containing an array of new orders:

{
  "resource": "document",
  "operation": "insert",
  "ConnectionUri": "{{ $credentials.mongodbAtlas }}",
  "Database": "ecommerce",
  "Collection": "orders",
  "Documents": [
    {
      "orderId": "ORD-2024-001847",
      "customerId": "CUST-10293",
      "customerEmail": "jane.doe@example.com",
      "status": "pending",
      "lineItems": [
        { "sku": "SHOE-BLK-42", "qty": 1, "unitPrice": 89.99 },
        { "sku": "SOCK-WHT-M",  "qty": 3, "unitPrice": 9.99  }
      ],
      "subtotal": 119.96,
      "shippingCost": 5.95,
      "total": 125.91,
      "shippingAddress": {
        "line1": "42 Elm Street",
        "city": "Austin",
        "state": "TX",
        "zip": "78701"
      },
      "createdAt": "{{ $now }}",
      "tenantId": "tenant_acme"
    }
  ],
  "Ordered": true
}

Validation Errors

ErrorCause
connectionUri is requiredConnectionUri is empty, null, or not provided.
database is requiredDatabase field is empty or whitespace.
collection is requiredCollection field is empty or whitespace.
documents array cannot be emptyDocuments is null, an empty array [], or not an array type.
INSERT_FAILEDMongoDB rejected one or more documents — possible causes include a unique index violation (duplicate key), schema validation rule failure, or a document exceeding the 16 MB BSON size limit.
Ordered vs unordered failure behaviour: With Ordered: true, insertion stops at the first error and the error port fires. With Ordered: false, all documents are attempted and insertedCount reflects only the successful ones — the success port still fires. Always check insertedCount against the input length when using unordered mode.

Output — Success Port

FieldTypeDescription
insertedCountintegerNumber of documents successfully inserted. With Ordered: true this is either the full count or 0. With Ordered: false it may be less than the number of input documents if some failed.
insertedIdsarrayArray of MongoDB ObjectID strings assigned to each successfully inserted document, in the same order as the input Documents array.
statusstringAlways "success" on the success port.
resourcestringAlways "document".
operationstringAlways "insert".

Sample Output

{
  "insertedCount": 2,
  "insertedIds": [
    "6651a3f2c4e8b9d0a1f23456",
    "6651a3f2c4e8b9d0a1f23457"
  ],
  "status": "success",
  "resource": "document",
  "operation": "insert"
}

Expression Reference

ExpressionReturnsDescription
{{ $output.InsertNode.insertedCount }}integerHow many documents were inserted. Compare to input array length to detect partial failures in unordered mode.
{{ $output.InsertNode.insertedIds }}arrayFull array of new document IDs. Pass to a Loop node to process each inserted record.
{{ $output.InsertNode.insertedIds[0] }}stringThe ObjectID of the first inserted document. Use to link to the created record immediately downstream.
{{ $output.InsertNode.insertedIds[0] | string }}stringExplicit string cast of the first ID for use in downstream query filters or HTTP request bodies.
{{ $output.InsertNode.status }}stringConfirm "success" for conditional branching after the node.

Node Policies & GuardRails

PolicyRecommendation
Credential storageAlways store the MongoDB connection string in BizFirst Credentials Manager and reference it via {{ $credentials.credentialName }}. Never paste the raw URI containing a password directly into the ConnectionUri field.
Document size limitMongoDB enforces a hard 16 MB per-document BSON limit. If inserting large documents (e.g. those with embedded binary content), validate sizes upstream or store large payloads in S3 and store a reference URL instead.
Idempotency for retriesIf your workflow may retry on transient errors, use a natural unique key (e.g. orderId, externalRef) as a custom _id field and ensure a unique index exists on that field. An upsert via document/update is often safer than insert for retry-safe workflows.
Bulk insert orderingSet Ordered: false for high-volume event ingestion pipelines where individual document failures should not block the batch. Set Ordered: true when documents have a logical dependency (e.g. inserting a parent before children in the same batch).
Multi-tenancy isolationAlways include a tenantId field in every document for multi-tenant applications. Define an index on tenantId and enforce it in all downstream queries so tenant data cannot leak across boundaries.
Schema validationConfigure MongoDB collection-level schema validation rules ($jsonSchema) to reject malformed documents at the database layer rather than relying solely on workflow-level validation. This provides defence-in-depth for direct database writes from other sources.
Index on write-heavy fieldsIf downstream workflows frequently query by status, customerId, createdAt, or tenantId, ensure compound indexes exist before inserting large volumes. Inserting millions of documents without indexes causes subsequent find operations to scan the full collection.
Error port handlingAlways connect the error port to a notification or logging node. Unhandled insert failures silently drop data in automated pipelines.

Workflow Examples

Example 1 — Single Order Insert on Checkout Webhook

{
  "resource": "document",
  "operation": "insert",
  "ConnectionUri": "{{ $credentials.mongodbAtlas }}",
  "Database": "ecommerce",
  "Collection": "orders",
  "Documents": [
    {
      "orderId":       "{{ $json.orderId }}",
      "customerId":    "{{ $json.customerId }}",
      "status":        "pending",
      "total":         "{{ $json.cartTotal }}",
      "currency":      "USD",
      "items":         "{{ $json.cartItems }}",
      "createdAt":     "{{ $now }}",
      "tenantId":      "{{ $json.tenantId }}"
    }
  ],
  "Ordered": true
}

Example 2 — Bulk Sensor Data Insert (Unordered)

{
  "resource": "document",
  "operation": "insert",
  "ConnectionUri": "{{ $credentials.mongodbIoT }}",
  "Database": "iot_platform",
  "Collection": "sensor_readings",
  "Documents": "{{ $json.readings }}",
  "Ordered": false
}

Where $json.readings is an array such as:

[
  { "sensorId": "TEMP-001", "value": 22.4, "unit": "C", "recordedAt": "2024-11-15T08:00:00Z", "siteId": "PLANT-A" },
  { "sensorId": "TEMP-002", "value": 23.1, "unit": "C", "recordedAt": "2024-11-15T08:00:00Z", "siteId": "PLANT-A" },
  { "sensorId": "HUM-001",  "value": 58.2, "unit": "%", "recordedAt": "2024-11-15T08:00:00Z", "siteId": "PLANT-A" }
]

Example 3 — Audit Log Entry After Approval Decision

{
  "resource": "document",
  "operation": "insert",
  "ConnectionUri": "{{ $credentials.mongodbAtlas }}",
  "Database": "compliance",
  "Collection": "audit_log",
  "Documents": [
    {
      "eventType":    "APPROVAL_DECISION",
      "workflowId":   "{{ $workflow.id }}",
      "runId":        "{{ $execution.id }}",
      "actorId":      "{{ $json.approverId }}",
      "actorEmail":   "{{ $json.approverEmail }}",
      "decision":     "{{ $json.decision }}",
      "comments":     "{{ $json.comments }}",
      "targetType":   "PurchaseOrder",
      "targetId":     "{{ $json.purchaseOrderId }}",
      "timestamp":    "{{ $now }}",
      "tenantId":     "{{ $json.tenantId }}"
    }
  ],
  "Ordered": true
}