Skip to content

Instantly share code, notes, and snippets.

@j-coll
Last active May 15, 2017 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j-coll/8e9ace0b24c9f65fa99be64ebae5a9bb to your computer and use it in GitHub Desktop.
Save j-coll/8e9ace0b24c9f65fa99be64ebae5a9bb to your computer and use it in GitHub Desktop.
// Use migration script https://gist.github.com/j-coll/c2b81a7ff8392ec6b5208b5a8bf0d3d3
var otherKeys = {
_id : "",
end : "",
ref : "",
alt : ""
};
migrateCollection("stage", {"_i" : {"$exists" : false} }, {}, function(bulk, doc) {
var _i = [];
for (var i in doc) {
if (!otherKeys.hasOwnProperty(i)) {
_i.push(i);
}
}
bulk.find({ "_id" : doc._id}).updateOne({ "$set" : {"_i" : _i} });
});
db.stage.ensureIndex( {"_i" : 1}, {"background" : true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment