Created
August 26, 2013 23:45
-
-
Save foo4u/6348058 to your computer and use it in GitHub Desktop.
Editing each element in a MongoDB collection returned by find() using an integer to assign a unique value to a string field.
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
var foo = 0; | |
db.collection.find().forEach( function(doc) { doc.slug = (++foo).toString(); db.collection.save(doc); } ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment