Last active
August 29, 2015 14:13
-
-
Save elhoyos/2159548a97a49045c4c8 to your computer and use it in GitHub Desktop.
Update a document based on its current values
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
| // Type in a mongoshell | |
| // Credits: http://stackoverflow.com/questions/3788256/mongodb-updating-documents-using-data-from-the-same-document/3792958#3792958 | |
| db.currencies.find({symbol: "$"}).snapshot().forEach( | |
| function (e) { | |
| e.customSymbol = e.code.substr(0, 2) + e.customSymbol; | |
| db.currencies.save(e); | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment