also update anon configs

pull/138/head
Thibault Duplessis 2014-11-30 14:29:50 +01:00
parent 7dbdef906f
commit ed7b30f512
1 changed files with 16 additions and 14 deletions

View File

@ -1,16 +1,18 @@
db.config.find().forEach(function(o) {
var sets = {};
var unsets = {};
['friend', 'hook', 'ai'].forEach(function(type) {
if (!o[type]) return;
sets[type + '.tm'] = o[type].k ? NumberInt(1) : NumberInt(0);
sets[type + '.d'] = NumberInt(2);
unsets[type + '.k'] = true;
});
db.config.update({
_id: o._id
}, {
$set: sets,
$unset: unsets
[db.config, db.config_anon].forEach(function(coll) {
coll.find().forEach(function(o) {
var sets = {};
var unsets = {};
['friend', 'hook', 'ai'].forEach(function(type) {
if (!o[type]) return;
sets[type + '.tm'] = o[type].k ? NumberInt(1) : NumberInt(0);
sets[type + '.d'] = NumberInt(2);
unsets[type + '.k'] = true;
});
coll.update({
_id: o._id
}, {
$set: sets,
$unset: unsets
});
});
});