-
-
Save leopd/6367453 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
function add_rand_field(collection) { | |
collection.find().forEach(function(data) { | |
collection.update({_id:data._id}, { | |
$set:{rand:Math.random()} | |
}); | |
}); | |
collection.ensureIndex({rand:1},{background:true}) | |
} | |
add_rand_field(db.mycoll); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment