Skip to content
Snippets Groups Projects
Commit e91969a6 authored by Markus Grigull's avatar Markus Grigull
Browse files

Add proper logging to models

parent 9ad71516
No related branches found
No related tags found
1 merge request!5Resolve "Add log level config option"
This commit is part of merge request !5. Comments created here will be created in the context of that merge request.
......@@ -23,6 +23,7 @@
var mongoose = require('mongoose');
var Visualization = require('./visualization');
var logger = require('../utils/logger');
var Schema = mongoose.Schema;
......@@ -39,12 +40,14 @@ projectSchema.pre('remove', function(callback) {
this.visualizations.forEach(function(id) {
Visualization.findOne({ _id: id }, function(err, visualization) {
if (err) {
return console.log(err);
logger.error('Unable to find visualization for id: ' + id, err);
return;
}
visualization.remove(function(err) {
if (err) {
return console.log(err);
logger.error('Unable to remove visualization', { err, visualization });
return;
}
});
});
......
......@@ -24,6 +24,7 @@
var SimulationModel = require('./simulationModel');
var Project = require('./project');
var logger = require('../utils/logger');
var Schema = mongoose.Schema;
......@@ -42,12 +43,14 @@
this.models.forEach(function(id) {
SimulationModel.findOne({ _id: id }, function(err, model) {
if (err) {
return console.log(err);
logger.error('Unable to find simulation model for id: ' + id, err);
return;
}
model.remove(function(err) {
if (err) {
return console.log(err);
logger.error('Unable to remove simulation model', { err, model });
return;
}
});
});
......@@ -57,12 +60,14 @@
this.projects.forEach(function(id) {
Project.findOne({ _id: id }, function(err, project) {
if (err) {
return console.log(err);
logger.error('Unable to find project for id: ' + id, err);
return;
}
project.remove(function(err) {
if (err) {
return console.log(err);
logger.error('Unable to remove project', { err, project });
return;
}
});
});
......
......@@ -85,12 +85,14 @@ userSchema.pre('remove', function(callback) {
this.projects.forEach(function(id) {
Project.findOne({ _id: id }, function(err, project) {
if (err) {
return console.log(err);
logger.error('Unable to find project for id: ' + id, err);
return;
}
project.remove(function(err) {
if (err) {
return console.log(err);
logger.error('Unable to remove project', { err, project });
return;
}
});
});
......@@ -100,12 +102,14 @@ userSchema.pre('remove', function(callback) {
this.simulations.forEach(function(id) {
Simulation.findOne({ _id: id }, function(err, simulation) {
if (err) {
return console.log(err);
logger.error('Unable to find simulation for id: ' + id, err);
return;
}
simulation.remove(function(err) {
if (err) {
return console.log(err);
logger.error('Unable to remove simulation', { err, simulation });
return;
}
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment