Is there a way to modify the id of all documents in a Mongo collection with spring mongo?
Trying this in many ways I got error messages like:
the (immutable) field '_id' was found to have been altered to _id
or
Write errors: [BulkWriteError{index=0, code=16837, message='The _id field cannot be changed from {_id: "xyz"} to {_id: "zxy"}.
Is there a way to do this?
No, you are not allowed to update the _id field. But you can always set a brand new _id to an existing doc and remove the older _id.