I have a requirement to update a single field of a whole collection in a MongoDB
database. However this should update a different value for each document.
e.g.
document 1 ‘key’ value should be changed to ‘dgsddhss35235’
document 2 ‘key’ value should be changed to ‘gdsdashsd1251’
There is no connection between the current value and the new value. Just that it has to be different in each document. However, the collection has close to 1 million documents with each documents containing a lot of information in multiple fields. Therefore, updating each document one by one takes many hours.
I tried bulkWrite
with batches on documents (e.g.100, 200 documents at a time). However, this still takes a huge amount of time and I am trying to find a better method to accomplish this task.