Skip to content

Instantly share code, notes, and snippets.

@fabiocarneiro
Last active August 29, 2015 14:20
Show Gist options
  • Save fabiocarneiro/cb539c48bd115fbcc0ca to your computer and use it in GitHub Desktop.
Save fabiocarneiro/cb539c48bd115fbcc0ca to your computer and use it in GitHub Desktop.
0 undefined
1 undefined
>
var count = 0;
var c = db.Supplier.find();
while(c.hasNext()) {
var i = c.next();
var col = i.supplies;
for (j in col) {
col[j].price = {
wholesalePrice: col[j].price,
retailPrice: col[j].suggestedPrice
};
delete col[j].suggestedPrice;
}
print(count++, db.Supplier.update({id: i._id}, {$set: {supplies: col}}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment