mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Rewriting stuff
This commit is contained in:
31
server/apps/rewrite.js
Normal file
31
server/apps/rewrite.js
Normal 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);
|
||||
});*/
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user