search

Home  >  Q&A  >  body text

mongodb _id rename

I am new to mongodb, how do I rename the _id of an entry?

淡淡烟草味淡淡烟草味2760 days ago1044

reply all(3)I'll reply

  • typecho

    typecho2017-06-16 09:21:03

    _id is the primary key of mongodb and cannot be renamed.

    reply
    0
  • 習慣沉默

    習慣沉默2017-06-16 09:21:03

    _id is automatically generated by mongodb if you do not set it, or you can directly give a value, but as for the renaming mentioned by lz, it seems that it is not possible.

    reply
    0
  • 怪我咯

    怪我咯2017-06-16 09:21:03

    Renaming is not possible. If you really want to change the _id, you can try to create a new data and specify the _id, then copy the original data and delete the original data.

    reply
    0
  • Cancelreply