Created
January 20, 2011 16:31
-
-
Save mediocretes/788131 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
migrate_one_faster = function(c) { | |
print("Collection: " + c); | |
print("Initial Count: " + db[c].count()); | |
i = 0; | |
db[c].find({created_at:{$exists:true}}).forEach(function(item){ | |
if(i++ % 10000 == 0){ print("progress: " + i);} | |
item.timestamp = item.created_at; | |
delete item.created_at; | |
db[c].save(item); | |
print(tojson(db.getLastErrorObj())); | |
}); | |
} | |
//prints this: | |
{ | |
"theshard" : "set1/mongo-1a.public.aws.igodigital.net:27017,mongo-1b.public.aws.igodigital.net:27017,mongo-1d.public.aws.igodigital.net:27017", | |
"err" : null, | |
"n" : 0, | |
"lastOp" : NumberLong(0), | |
"ok" : 1, | |
"singleShard" : "set1/mongo-1a.public.aws.igodigital.net:27017,mongo-1b.public.aws.igodigital.net:27017,mongo-1d.public.aws.igodigital.net:27017" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment