Rewriting stuff

This commit is contained in:
Kasper Rynning-Tønnesen
2018-02-27 11:26:31 +01:00
parent 370e9ae72b
commit d2b3759913
4 changed files with 39 additions and 3 deletions

31
server/apps/rewrite.js Normal file
View File

@@ -0,0 +1,31 @@
path = require('path'),
pathThumbnails = __dirname;
db = require(pathThumbnails + '/../handlers/db.js');
db.getCollectionNames(function(err, docs) {
for(var i = 0; i < docs.length; i++) {
makeNewAndDelete(docs[i]);
}
})
/*function delete(name) {
db.collection(name).remove(function(err, doc) {
})
}*/
function makeNewAndDelete(name) {
db.collection(name).find({views: {$exists: true}}, function(err, doc) {
//console.log(doc);
if(doc.length == 0) {
//console.log(name);
} else if(doc.length == 1) {
db.collection(name + "_settings").insert(doc[0], function(err, result){
console.log("Result insert", result);
/*db.collection(name).remove({views: {$exists: true}}, function(err, result_del) {
console.log("Result delete", result_del);
});*/
});
}
});
}