Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var bulk = db.users.initializeOrderedBulkOp();
- var count = 0;
- db.users.find({}).forEach(function(doc) {
- bulk.find({ "_id": doc._id }).updateOne({
- "$set": {
- "last_name": doc.last_name.toUpperCase(),
- "first_name": doc.first_name.toUpperCase()
- }}
- );
- count++;
- if ( count % 500 == 0 ) {
- bulk.execute();
- bulk = db.users.initializeOrderedBulkOp();
- count = 0;
- }
- });
- if ( count > 0 )
- bulk.execute();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement