use lean and .update
This commit is contained in:
committed by
Phillip Thelen
parent
e8b7dbb4d2
commit
577ff4cab9
@@ -8,23 +8,25 @@ let count = 0;
|
||||
async function updateUser (user) {
|
||||
count++;
|
||||
|
||||
user.migration = MIGRATION_NAME;
|
||||
const set = {};
|
||||
|
||||
set.migration = MIGRATION_NAME;
|
||||
|
||||
if (user.items.pets['Bear-Veteran']) {
|
||||
user.items.pets['Fox-Veteran'] = 5;
|
||||
set['items.pets.Fox-Veteran'] = 5;
|
||||
} else if (user.items.pets['Lion-Veteran']) {
|
||||
user.items.pets['Bear-Veteran'] = 5;
|
||||
set['items.pets.Bear-Veteran'] = 5;
|
||||
} else if (user.items.pets['Tiger-Veteran']) {
|
||||
user.items.pets['Lion-Veteran'] = 5;
|
||||
set['items.pets.Lion-Veteran'] = 5;
|
||||
} else if (user.items.pets['Wolf-Veteran']) {
|
||||
user.items.pets['Tiger-Veteran'] = 5;
|
||||
set['items.pets.Tiger-Veteran'] = 5;
|
||||
} else {
|
||||
user.items.pets['Wolf-Veteran'] = 5;
|
||||
set['items.pets.Wolf-Veteran'] = 5;
|
||||
}
|
||||
|
||||
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
|
||||
|
||||
return await user.save();
|
||||
return await User.update({_id: user._id}, {$set: set}).exec();
|
||||
}
|
||||
|
||||
module.exports = async function processUsers () {
|
||||
@@ -46,6 +48,7 @@ module.exports = async function processUsers () {
|
||||
.limit(250)
|
||||
.sort({_id: 1})
|
||||
.select(fields)
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
if (users.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user