mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-11 00:02:19 -05:00
21 lines
644 B
JavaScript
21 lines
644 B
JavaScript
var usersWithPurchases = db.users.find({"purchased.items": {$exists: true}}).toArray();
|
|
var itemsConverted = 0;
|
|
var usersConverted = 0;
|
|
for (var i = 0; i < usersWithPurchases.length; ++i) {
|
|
var user = usersWithPurchases[i];
|
|
var items = user.purchased.items;
|
|
var convertThisUser = false;
|
|
for (var j = 0; j < items.length; ++j) {
|
|
var item = items[j];
|
|
if (typeof item != 'string') {
|
|
items[j] = '' + item;
|
|
++itemsConverted;
|
|
convertThisUser = true;
|
|
}
|
|
}
|
|
if (convertThisUser) {
|
|
db.users.save(user);
|
|
++usersConverted;
|
|
}
|
|
}
|
|
print("Had to convert", itemsConverted, "items and", usersConverted, "users");
|