07-31-2023, 09:21 AM
Ok, I suppose that this is a silly question and probably has a simple answer.
How can I duplicate a document in MongoDB, changing the _id of the new one?
Imaging that you have the original document:
> var orig = db.MyCollection.findOne({_id: 'hi'})
And now I want another document in the collection with _id 'bye'.
How can I duplicate a document in MongoDB, changing the _id of the new one?
Imaging that you have the original document:
> var orig = db.MyCollection.findOne({_id: 'hi'})
And now I want another document in the collection with _id 'bye'.