Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
CV.findOneAndRemove({id: id}, function(err, cv){
if (err) {
log.error({err: err, cv: id}, 'error deleting cv');
return cb(Boom.internal());
}
if (!cv) {
log.error({err: 'not found', cv: id}, 'error deleting cv');
return cb(Boom.notFound());
}
return cb(null, cv);
});
}
User.findOneAndRemove({id: id}, function(err, user){
if (err) {
log.error({err: err, requestedUser: id}, 'error deleting user');
return cb(Boom.internal());
}
if (!user) {
log.error({err: err, requestedUser: id}, 'error deleting user');
return cb(Boom.notFound());
}
return cb(null, user);
});
}
CV.create(cv, function(err, _cv) {
if (err) {
if(err.code == 11000) {
return cb(Boom.conflict('cv is a duplicate'));
}
log.error({err: err, cv: cv.id}, 'error creating cv');
return cb(Boom.internal());
}
cb(null, _cv.toObject({ getters: true }));
});
}
CV.findOne({id: id}, fields, function(err, cv) {
if (err) {
log.error({err: err, cv: id}, 'error getting cv');
return cb(Boom.internal());
}
if (!cv) {
log.error({err: 'not found', cv: id}, 'error getting cv');
return cb(Boom.notFound());
}
cb(null, cv);
});
}
Meeting.create(meeting, function(err, _meeting) {
if (err) {
log.error({ err: err, meeting: meeting}, 'error creating meeting');
return cb(Boom.internal());
}
cb(null, _meeting);
});
}
User.find(filter, fields, options, function(err, users) {
if (err) {
log.error({err: err}, 'error getting all users');
return cb(Boom.internal());
}
cb(null, users);
});
}
CV.findOneAndUpdate({id: id}, cv, options, function(err, _cv) {
if (err) {
log.error({err: err, cv: id}, 'error updating cv');
return cb(Boom.internal());
}
if (!_cv) {
log.error({err: err, cv: id}, 'error updating cv');
return cb(Boom.notFound());
}
cb(null, _cv.toObject({ getters: true }));
});
}
Meeting.find(filter,fields,options, function(err, meetings) {
if (err) {
log.error({ err: err}, 'error getting all meetings');
return cb(Boom.internal());
}
cb(null, meetings);
});
}
User.create(user, function(err, _user) {
if (err) {
if(err.code == 11000) {
log.warn({err:err, requestedUser: user.id}, 'user is a duplicate');
return cb(Boom.conflict(dupKeyParser(err.err)+' is a duplicate'));
}
log.error({ err: err, user: user.id}, 'error creating user');
return cb(Boom.internal());
}
cb(null, _user.toObject({ getters: true }));
});
}
Meeting.findOneAndUpdate(filter, meeting, function(err, _meeting) {
if (err) {
log.error({ err: err, meeting: id}, 'error updating meeting');
return cb(Boom.internal());
}
if (!_meeting) {
log.warn({ err: 'not found', meeting: id}, 'error updating meeting');
return cb(Boom.notFound());
}
cb(null, _meeting);
});
}