What's the right way to partically update an object's key value in mongodb

Describe the problem/error/question

There is a document in mongodb:

{
  id: '1',
  tweet:{
    title: 'title'
  }
}

I want to update it’s tweet.content, turned on the ‘Use Dot notation’, expected to be something like:

{
  id: '1',
  tweet:{
    title: 'title',
    content:'content'
  }
}

but got result:

{
  id: '1',
  tweet:{
    content:'content'
  }
}

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

[
  {
    "tweet": {
      "content": "content"
    },
    "id": "1"
  }
]

Information on your n8n setup

  • n8n version: 0.225.2
  • Database (default: SQLite): mariadb
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: synology 7
  • Mongodb version: 4.4.21

Hi @painty, welcome to the community! The MongoDB node doesn’t seem to have a designated option for partial updates. So for now, you probably want to fetch the current data, then update the field you need to update, before running the actual update operation.

I’ll also convert this question into a feature request so you and other users can vote on having this implemented going forward.