🚀 Fixing MongoDB Updates in n8n (No More Workarounds!)

If you’ve ever used MongoDB with n8n, you’ve probably hit this limitation.

The MongoDB node in n8n doesn’t actually support real MongoDB update operations.

Yeah… that surprised me too.


:face_with_steam_from_nose: The Problem

The existing update functionality is extremely limited:

  • Only allows updating a single field
  • Uses updateKey + value
  • Internally tied to updateOne

That means no support for native MongoDB update operators like:

  • $set (multiple fields)
  • $pull
  • $push
  • $rename
  • $inc

:exploding_head: Real-world limitation

Let’s say you want to remove a value from an array:

{
  "$pull": {
    "tags": "deprecated"
  }
}

:backhand_index_pointing_right: Not possible in the current node.

Or update multiple fields:

{
  "$set": {
    "status": "active",
    "updatedAt": "2026-01-01"
  }
}

:brain: The Workarounds (that shouldn’t exist)

Because of this, developers are forced to:

  • Use aggregation pipelines :grimacing:
  • Add Code nodes :exploding_head:
  • Chain multiple operations :face_with_crossed_out_eyes:
    This defeats the purpose of using a low-code tool like n8n.

##:light_bulb: The Fix

I created a PR that enables JSON-based update operations in the MongoDB node.

:white_check_mark: What’s new?

You can now define:

  • A JSON filter
  • A JSON update object
    :backhand_index_pointing_right: Just like native MongoDB.

##:fire: Before vs After

:cross_mark: Before

  • One field update only
  • No operators
  • Limited flexibility

:white_check_mark: After (JSON Mode)

{
  "filter": {
    "userId": "123"
  },
  "update": {
    "$set": {
      "status": "active"
    },
    "$inc": {
      "loginCount": 1
    }
  }
}

:backhand_index_pointing_right: Clean
:backhand_index_pointing_right: Flexible
:backhand_index_pointing_right: Powerful

:hammer_and_wrench: What this unlocks

This change enables:

  • Updating multiple fields in one operation.
  • Using advanced operators like $pull, $push, $rename.
  • Writing cleaner workflows.
  • Removing unnecessary Code nodes.
  • Aligning with native MongoDB behavior.

:gear: How it works

A new mode is introduced:

  1. Simple Mode (existing)
  • Uses updateKey
  • No changes
  1. JSON Mode (new)
    Accepts raw JSON:
  • Filter
  • Update object
    :backhand_index_pointing_right: Fully opt-in
    :backhand_index_pointing_right: No breaking changes

:test_tube: Stability
:white_check_mark: Backward compatible
:white_check_mark: Input validation (invalid / empty JSON)
:white_check_mark: Unit tests added
:white_check_mark: All existing tests passing
:bullseye: Why this matters

n8n is powerful because it bridges the gap between code and no-code.

But limitations like this push developers back into writing code — unnecessarily.

This change:

:check_mark: Reduces friction
:check_mark: Improves flexibility
:check_mark: Matches real MongoDB capabilities
:check_mark: Saves time for developers

:rocket: PR Link

:backhand_index_pointing_right: https://github.com/n8n-io/n8n/pull/27583

Would love feedback from the community and maintainers!

:speech_balloon: Final thought

Sometimes the most impactful improvements aren’t flashy…

They’re the ones that remove everyday friction.

This is one of them.

2 Likes