MongoDB update / find and update running but not working for me

Describe the problem/error/question

I have a workflow in which I use MongoDB Find to get all entries in my collection. I Edit one of the fields using “Edit Fields”, and then I iterate a loop to Update that field on MongoDB.

I have tried everything I could think of:

  1. I tried using only Update
  2. Tried Find and Update without a loop
  3. Tried using _id as “Update Key”, but no data returned on Update/Find and Update, so I started using the name of the field to be updated, which is unieque (AffiliateURL): in this case the node returns the data as if it were updated, but it is not.
  4. Tried passing the Update Key and Fields using like {{ $json.AffiliateURL }}, no luck there neither.

What is the error message (if any)?

No errors

Please share your workflow

Share the output returned by the last node

The AffiliateURL is showing as updated as expected, but this is not reflected in the database, which has the older value.

Information on your n8n setup

  • n8n version: 1.53.1
  • Database (default: SQLite): Postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main): I have no idea
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Ubuntu

Hi @joaotextor

Thanks for posting here and welcome to the community! :partying_face:

If you check the JSON output of your Edit Fields Node, it will probably be showing something like this (double quotes)


Unfortunately this is a bug with the Set Node and we’re working on fixing this.

When you deactivate the “Always Output Data” toggle in your MongoDB Find & Update Node settings, you should be seeing the error from MongoDB as well.

You should be able to bypass that though by deleting the _id value from the Edit Fields node.

Thanks for the reply. I tried excluding _id in the “Edit Fields” node, and it did not work either.

Result is the same: Find and Update will run, return the update field but does not commit to database.

1 Like

I have the same issues, anybody knows if its about a n8n internal problem?

@EmeraldHerald do you know something?

Hi! I was able to solve this issue. Actually it was my mistake to use the same field AffiliateURL both in “Update Key” and “Fields” inputs. In “Update Key” you should put some other field in your database. Then, in “Fields” you pass the corresponding inputs that will be changed in the database.

Explanation: as you can see in my example above, I had only AffiliateURL in both fields. MongoDB Node was trying to find that value in the collections in the AffiliateURL property, but I was passing the already updated one, so it would never work. I had to put another field in Update Key (in my case, I had put “productName”, which wasn’t going to be updated), then it will work fine.

2 Likes