I need to copy one collection to another server and change a value in every document. The collection is very large, therefore, to save time, instead of copying the collection and modifying the data, I was wondering if there could be a script that while it goes through the documents, it changes the value before it inserts the documents to another server. Modification is pretty much padding a field with 0s.
For example:
Source : server1:27017
db.students:
{"_id" : ObjectId("..."), "sId" : "1234", "grade" : 4 }
{"_id" : ObjectId("..."), "sId" : "4444", "grade" : 3 }
{"_id" : ObjectId("..."), "sId" : "5555", "grade" : 5 }
Destination: server2:27017
db.students:
{"_id" : ObjectId("..."), "sId" : "0001234", "grade" : 4 }
{"_id" : ObjectId("..."), "sId" : "0004444", "grade" : 3 }
{"_id" : ObjectId("..."), "sId" : "0005555", "grade" : 5 }