0

I just want to know that how will I update the existing record _id by its _id. It means that suppose there is a record and that having an objectId given like below:

"_id" : ObjectId("5b3b5607638ea66f51508913"),

And I want to update this id into a integer. I also read the mongodb documentation of updation but it only update the other field how will I update the id to the integer form like "_id" : 1, this. Is there any method of doing this.

ansh
  • 35
  • 1
  • 11
  • @ansh No, you can't. You must to create a new document and remove the old one. Take a look into https://stackoverflow.com/questions/4012855/how-update-the-id-of-one-mongodb-document – Neodan Jul 03 '18 at 12:10
  • You can update BY id. You can't update THE id. It's two different questions. – Sergio Tulentsev Jul 03 '18 at 12:11

0 Answers0