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:
I tried using only Update
Tried Find and Update without a loop
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.
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.
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.