How update the _id of one MongoDB Document?

I want update an _id field of one document. I know it's not a really good pratice. But with some technical reason, I need update it. If I try to update it I get:

> db.clients.update({ _id: ObjectId("123")}, { $set: { _id: ObjectId("456")}})

Performing an update on the path '_id' would modify the immutable field '_id'

And the update is not made. How I can update it?

задан Gianfranco P. 20 August 2019 в 13:09