Created
September 9, 2015 08:32
-
-
Save marcoberri/be64c36c86135d81f4e0 to your computer and use it in GitHub Desktop.
MongoDB - Rigenerare il _id per ogni documento
This file contains hidden or 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
| use test; | |
| var coll = db.events; | |
| var coll_new = db.events_new; | |
| var cursor = coll.find(); | |
| cursor.forEach(function(doc) { | |
| delete doc._id; | |
| coll_new.save(doc); | |
| }); | |
| coll_new.renameCollection("events",true); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment