DBAtlas · Database operations atlas

66: ImmutableField (cannot update _id)

MongoDB

What does it mean?

An attempt was made to update an immutable field, typically the document's _id field. _id cannot be changed after the document is created.

Why does it happen?

An update attempting to change the _id field, updating a shard key field in a way that is not allowed, or setting a field treated as immutable to a new value.

How to fix it

Do not update the _id value; if a different _id is needed, insert the document with the new _id and delete the old one (insert + delete). Follow MongoDB rules for shard key updates. Remove immutable fields from the update document and set only modifiable fields.

Open in DBAtlas →

More from this engine