Skip to content

Commit

Permalink
changed request.remove with request.findOneAndDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
Giovanni Troisi committed Feb 15, 2024
1 parent 628beeb commit d8601e1
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions routes/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,7 @@ router.delete('/:requestid', function (req, res) {
winston.verbose('Messages deleted for the recipient: ' + req.params.requestid);
});


Request.remove({ request_id: req.params.requestid }, function (err, request) {
Request.findOneAndDelete({ request_id: req.params.requestid }, (err, request) => {
if (err) {
winston.error('--- > ERROR ', err);
return res.status(500).send({ success: false, msg: 'Error deleting object.' });
Expand All @@ -817,8 +816,25 @@ router.delete('/:requestid', function (req, res) {
requestEvent.emit('request.delete', request);

res.json(request);
})

});
// Request.remove({ request_id: req.params.requestid }, function (err, request) {
// if (err) {
// winston.error('--- > ERROR ', err);
// return res.status(500).send({ success: false, msg: 'Error deleting object.' });
// }

// if (!request) {
// return res.status(404).send({ success: false, msg: 'Object not found.' });
// }

// winston.verbose('Request deleted with request_id: ' + req.params.requestid);

// requestEvent.emit('request.delete', request);

// res.json(request);

// });
});


Expand Down

0 comments on commit d8601e1

Please sign in to comment.