Last active
December 27, 2017 17:23
-
-
Save adrianlemess/87002072a9ac6a75be0dc61c51d3fc81 to your computer and use it in GitHub Desktop.
Atualizar todos os campos com um valor do próprio documento do Mongo
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
| //Em um shell mongo colocar o seguinte script | |
| db.person.find().snapshot().forEach( | |
| function (elem) { | |
| db.person.update( | |
| { | |
| _id: elem._id | |
| }, | |
| { | |
| $set: { | |
| name: elem.firstname + ' ' + elem.lastname | |
| } | |
| } | |
| ); | |
| } | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment