Technology Apr 16, 2026 · 2 min read

๐Ÿš€ 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. ๐Ÿ˜ค The Problem The existing update functionality is extremely limited: Only allows updating a...

DE
DEV Community
by Milan K Jain
๐Ÿš€ 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.

๐Ÿ˜ค 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

๐Ÿคฏ Real-world limitation

Letโ€™s say you want to remove a value from an array:

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

๐Ÿ‘‰ Not possible in the current node.

Or update multiple fields:

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

๐Ÿง  The Workarounds (that shouldnโ€™t exist)

Because of this, developers are forced to:

  • Use aggregation pipelines ๐Ÿ˜ฌ
  • Add Code nodes ๐Ÿคฏ
  • Chain multiple operations ๐Ÿ˜ต This defeats the purpose of using a low-code tool like n8n.

๐Ÿ’ก The Fix

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

โœ… Whatโ€™s new?

You can now define:

  • A JSON filter
  • A JSON update object ๐Ÿ‘‰ Just like native MongoDB.

๐Ÿ”ฅ Before vs After

โŒ Before

  • One field update only
  • No operators
  • Limited flexibility

โœ… After (JSON Mode)

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

๐Ÿ‘‰ Clean
๐Ÿ‘‰ Flexible
๐Ÿ‘‰ Powerful

๐Ÿ› ๏ธ 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.

โš™๏ธ How it works

A new mode is introduced:

  1. Simple Mode (existing)
  2. Uses updateKey
  3. No changes
  4. JSON Mode (new) Accepts raw JSON:
  5. Filter
  6. Update object ๐Ÿ‘‰ Fully opt-in ๐Ÿ‘‰ No breaking changes

๐Ÿงช Stability
โœ… Backward compatible
โœ… Input validation (invalid / empty JSON)
โœ… Unit tests added
โœ… All existing tests passing
๐ŸŽฏ 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:

โœ” Reduces friction
โœ” Improves flexibility
โœ” Matches real MongoDB capabilities
โœ” Saves time for developers

๐Ÿš€ PR Link

๐Ÿ‘‰ https://github.com/n8n-io/n8n/pull/27583

Would love feedback from the community and maintainers!

๐Ÿ’ฌ Final thought

Sometimes the most impactful improvements arenโ€™t flashyโ€ฆ

Theyโ€™re the ones that remove everyday friction.

This is one of them.

DE
Source

This article was originally published by DEV Community and written by Milan K Jain.

Read original article on DEV Community
Back to Discover

Reading List