Skip to content

Instantly share code, notes, and snippets.

@josenaves
Created July 19, 2013 16:42
Show Gist options
  • Save josenaves/6040590 to your computer and use it in GitHub Desktop.
Save josenaves/6040590 to your computer and use it in GitHub Desktop.
Insert ... select in mongodb
use admin_loja;
db.planos.find().forEach( function(plano) {
if (typeof(plano.deals) != 'undefined') {
for (i = 0; i < plano.deals.length; i++) {
produtos = plano.deals[i].produtos;
if (typeof(produtos) != 'undefined') {
for (j = 0; j < produtos.length; j++) {
if (typeof(produtos[j]) != 'undefined') {
produtos[j].maxPermittedPurchase = 0;
}
}
}
}
}
db.planosNovos.insert(plano);
});
//db.planos.drop();
db.planos.renameCollection("planosBackup");
db.planosNovos.renameCollection("planos");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment