mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-10-30 20:52:29 +01:00
21 lines
532 B
JavaScript
21 lines
532 B
JavaScript
function deleteId(h){
|
|
delete h._id;
|
|
}
|
|
|
|
db.users.find({},{habits:1,dailys:1,history:1}).forEach(function(user){
|
|
if (user.history) {
|
|
_.each(['todos','exp'], function(type){
|
|
if (user.history[type]) {
|
|
_.each(user.history.exp, deleteId);
|
|
}
|
|
})
|
|
} else {
|
|
user.history = {exp:[],todos:[]};
|
|
}
|
|
|
|
_.each(['habits', 'dailys'], function(type){
|
|
_.each(user[type].history, deleteId);
|
|
});
|
|
|
|
db.users.update({_id:user._id}, {$set:{history: user.history, habits: user.habits, dailys: user.dailys}});
|
|
}); |