Major refactor. Add error handlers everywhere.

This commit is contained in:
Berkeley Martinez
2014-12-23 08:48:28 -08:00
parent e921b637cc
commit 86fcfe8296
18 changed files with 1431 additions and 1529 deletions

View File

@@ -1,15 +1,22 @@
var Challenge = require('../models/Challenge.js')
var mongoose = require('mongoose');
var secrets = require('../config/secrets');
var challenges = require('./challenges.json');
var Challenge = require('../models/Challenge.js'),
mongoose = require('mongoose'),
secrets = require('../config/secrets'),
challenges = require('./challenges.json');
mongoose.connect(secrets.db);
Challenge.remove({}, function(err, data){
if (err) console.log(err);
else console.log('Deleted ', data );
Challenge.remove({}, function(err, data) {
if (err) {
console.error(err);
} else {
console.log('Deleted ', data);
}
Challenge.create(challenges, function(err, data) {
if (err) console.log(err);
else console.log('Saved ', data );
if (err) {
console.log(err);
} else {
console.log('Saved ', data);
}
process.exit(0);
});
});