Skip to content

Instantly share code, notes, and snippets.

@adrianlemess
Last active December 27, 2017 17:23
Show Gist options
  • Select an option

  • Save adrianlemess/87002072a9ac6a75be0dc61c51d3fc81 to your computer and use it in GitHub Desktop.

Select an option

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
//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