I have 2000 documents, and I want to add a new field (newUUID
) to each one and set its value based on an existing one (oldUUID
).
I'm running the following query:
var cursor1 = db.myCollection.find();
cursor1.forEach(function(results){ db.myCollection.update({_id: results._id}, {$set: {newUUID: results.oldUUID}})})
But the iteration takes a few long minutes
MongoDB server version: 3.6.0
MongoDB shell version v4.4.1