mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
[#1789] remove all undefined pets once and for all
This commit is contained in:
parent
f64ca7d4d0
commit
30d6f6c4d8
1 changed files with 12 additions and 0 deletions
12
migrations/20131117_remove_undefined_pets.js
Normal file
12
migrations/20131117_remove_undefined_pets.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// once and for all!
|
||||
|
||||
db.users.find({'items.pets':{$exists:1}},{'items.pets':1}).forEach(function(user){
|
||||
_.reduce(user.items.pets, function(m,v,k){
|
||||
if (!k.indexOf('undefined')) m.push(k);
|
||||
return m;
|
||||
}, []).forEach(function(key){
|
||||
delete user.items.pets[key];
|
||||
})
|
||||
|
||||
db.users.update({_id:user._id}, { $set:{'items.pets':user.items.pets} });
|
||||
});
|
||||
Loading…
Reference in a new issue