Major refactor. Add error handlers everywhere.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user