Skip to content

Commit

Permalink
(fix) Added ability to backup
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettjoecox committed Apr 17, 2015
1 parent b40b74b commit d708e8c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ client/build
keys.js
client/dist/**
out
data/siteData.txt
data/siteData.txt
backup.json
29 changes: 29 additions & 0 deletions server/helpers/backupDB.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

var Promise = require('bluebird');
var People = require('../database/people/model');
var twitterController = require('../database/twitter/controller');
var contextController = require('../database/context/controller');
var sitesController = require('../database/sites/controller');
var facebookController = require('../database/facebook/controller');
var topController = require('../database/top/controller');
var fs = require('fs-utils');

module.exports = function() {
return People.findAll()
.then(function(data) {
var promiseArray = [];
data.forEach(function(person) {
promiseArray.push(twitterController.attachData(person.get())
.then(contextController.attachData)
.then(sitesController.attachData)
.then(facebookController.attachData)
.then(topController.attachData));
});

return Promise.all(promiseArray);
}).then(function(data) {
fs.writeJSONSync('./data/backup.json', {people: data});
});
};

module.exports();

0 comments on commit d708e8c

Please sign in to comment.