Skip to content
Advertisement

node.js mongodb .. the (immutable) field ‘_id’ was found to have been altered

I have some problem when I try to upsert my object with new ones(parsed from xml file),but I got the following error:

JavaScript

Here is my code:

JavaScript

I tried to use hints like:

JavaScript

but they didn’t help. So I don’t want to update my product._id , I just want to update the other fields.

Advertisement

Answer

When you do new Product(), a new _id is generated, along with other things. Try this:

JavaScript
Advertisement