mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-07-27 17:32:26 +00:00
21 lines
553 B
JavaScript
21 lines
553 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}});
|
||
|
|
});
|