I need to add a field to every document inside a collection and copy. The value of the new field should be a field that already exists in the document.
The following solution is way to slow because it's about 400k documents and it only updates 80 documents a seconds roughly.
db.application.find().forEach(
function (elem) {
db.application.updateOne(
{_id: elem._id},
{$set: {sourceRaw: elem.source}}
)
}
);
Because of version 4.0 I can't use aggregations inside updateMany
or bulkWrite
.
Whats the fastest way to copy a field in AWS DocumentDB (MongoDB 4.0.0)?