mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-03 08:21:07 +00:00
Merge pull request #1654 from HabitRPG/paglias/remove-deleted-tags
Migration to remove deleted tags from tasks
This commit is contained in:
commit
da563042dc
1 changed files with 17 additions and 0 deletions
17
migrations/20131028_cleanup_deleted_tags.js
Normal file
17
migrations/20131028_cleanup_deleted_tags.js
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
_.each(db.users.find(), function(user){
|
||||
var tags = user.tags;
|
||||
|
||||
_.each(user.tasks, function(task){
|
||||
_.each(task.tags, function(val, key){
|
||||
_.each(tags, function(tag){
|
||||
if(key == tag.id) delete task.tags[key];
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
try {
|
||||
db.users.update({_id:user._id}, user);
|
||||
} catch(e) {
|
||||
print(e);
|
||||
}
|
||||
});
|
||||
Loading…
Reference in a new issue