Answer the question
In order to leave comments, you need to log in
How to delete the found entry from the database?
The code below displays the commands field from the collection. Help form it so that, before the output, the res.status
found record is deleted from the database and only then displayed.
Commands.find({ 'device': req.body.id })
.exec()
.then(cmd => {
if(cmd.length = 1){
res.status(200).json({
"commands": cmd[0].commands,
"result":"ok",
});
}
})
.catch(err => {
console.log(err);
res.status(500).json({
error: err
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question