Portal Community
Irreversible operation. Deleted documents cannot be recovered unless you have a separate backup or soft-delete architecture in place. Always verify your query filter using document/find first to confirm the exact documents that will be removed. Never use Query: {} with DeleteMany: true in production — this deletes every document in the collection.

When to Use

Configuration

Connection

FieldRequiredDescription
ConnectionUriRequiredMongoDB connection string. Reference via {{ $credentials.mongodbAtlas }}.
DatabaseRequiredTarget database name.
CollectionRequiredTarget collection name.

Operation

FieldRequiredDescription
QueryOptionalFilter identifying documents to delete. Default {} matches all documents — use only when intentionally wiping a collection (development/test only). Always include precise constraints: IDs, date ranges, status flags, and tenantId for multi-tenant systems. Example: {"customerId": "CUST-10293", "tenantId": "tenant_acme"}.
DeleteManyOptionalDefault true. When true, all documents matching the filter are deleted. When false, only the first matching document (in natural collection order) is deleted. Set false for single targeted deletions such as removing a specific document by its _id.
Prefer soft-delete in production systems. For most business data, consider adding a deletedAt timestamp and isDeleted: true flag using document/update instead of permanently removing documents. Soft-delete preserves audit trails and allows recovery. Use hard delete only when legally required (GDPR erasure) or for non-critical cleanup scenarios.

Sample Configuration

Delete all expired session documents older than the current time:

{
  "resource": "document",
  "operation": "delete",
  "ConnectionUri": "{{ $credentials.mongodbAtlas }}",
  "Database": "auth",
  "Collection": "sessions",
  "Query": {
    "expiresAt": { "$lt": "{{ $now }}" },
    "tenantId": "{{ $json.tenantId }}"
  },
  "DeleteMany": true
}

Validation Errors

ErrorCause
connectionUri is requiredConnectionUri is empty or not provided.
database is requiredDatabase field is empty.
collection is requiredCollection field is empty.

Output — Success Port

FieldTypeDescription
deletedCountintegerNumber of documents permanently deleted. 0 means no documents matched the filter — the success port still fires in this case.
statusstringAlways "success".
resourcestringAlways "document".
operationstringAlways "delete".

Sample Output

{
  "deletedCount": 312,
  "status": "success",
  "resource": "document",
  "operation": "delete"
}

Expression Reference

ExpressionReturnsDescription
{{ $output.CleanupSessions.deletedCount }}integerNumber of documents removed. Use in downstream logging nodes or reports to record the volume of deleted data.
{{ $output.CleanupSessions.status }}stringConfirm "success" in a conditional branch before proceeding with dependent steps.
{{ $output.CleanupSessions.deletedCount == 0 }}booleanTrue when no documents were deleted. Use in IfCondition to detect no-op deletes and handle them distinctly from actual deletions.

Node Policies & GuardRails

PolicyRecommendation
Credential storageAlways reference ConnectionUri from BizFirst Credentials Manager. Never embed raw credentials in workflow node configuration.
Verify before deleteBefore a delete workflow runs in production for the first time, run the identical Query in a document/find node and inspect the results. Confirm the document set is exactly what you intend to remove.
Never use empty query in productionQuery: {} with DeleteMany: true deletes the entire collection. If you need this behaviour in development, use a dedicated flag field (e.g. {"environment": "test"}) and scope all queries to that flag.
Multi-tenancy filterAlways include tenantId in the Query filter for shared collections. Deleting across tenant boundaries is a critical data integrity failure.
Prefer soft-deleteFor business-critical collections (customers, orders, invoices), implement a soft-delete pattern using document/update with $set: {isDeleted: true, deletedAt: "{{ $now }}"}. Reserve hard delete for cleanup and GDPR erasure workflows.
Archive before deleteFor compliance-sensitive scenarios, use document/find to retrieve the documents and insert them into an archive collection before deleting. This preserves recoverable snapshots while satisfying the hard-delete requirement.
Index the query filterEnsure the Query fields are indexed. Unindexed deletes on large collections perform full scans and hold locks longer, blocking concurrent writes.
Error port handlingAlways connect the error port. A failed delete in a compliance or cleanup workflow should trigger an immediate alert rather than silently completing the parent workflow with partial data removal.

Workflow Examples

Example 1 — GDPR Right-to-Erasure Customer Data Deletion

{
  "resource": "document",
  "operation": "delete",
  "ConnectionUri": "{{ $credentials.mongodbAtlas }}",
  "Database": "crm",
  "Collection": "customers",
  "Query": {
    "customerId": "{{ $json.customerId }}",
    "tenantId": "{{ $json.tenantId }}",
    "deletionRequestId": { "$exists": true }
  },
  "DeleteMany": false
}

Example 2 — Expired Token Cleanup (Scheduled Nightly)

{
  "resource": "document",
  "operation": "delete",
  "ConnectionUri": "{{ $credentials.mongodbAtlas }}",
  "Database": "auth",
  "Collection": "refresh_tokens",
  "Query": {
    "expiresAt": { "$lt": "{{ $now }}" }
  },
  "DeleteMany": true
}

Example 3 — Workflow Staging Record Cleanup

{
  "resource": "document",
  "operation": "delete",
  "ConnectionUri": "{{ $credentials.mongodbAtlas }}",
  "Database": "workflow_engine",
  "Collection": "staging_data",
  "Query": {
    "workflowRunId": "{{ $execution.id }}",
    "stage": "intermediate"
  },
  "DeleteMany": true
}