Project e Todos sistemati...
aggiunti Gruppi
This commit is contained in:
@@ -152,7 +152,6 @@ router.get('/test', (req, res) => {
|
||||
descr: "Primo Task Esempio",
|
||||
enableExpiring: false,
|
||||
expiring_at: new Date(),
|
||||
id_prev: null,
|
||||
modified: false,
|
||||
modify_at: new Date(),
|
||||
pos: 1,
|
||||
@@ -193,22 +192,38 @@ router.get('/', (req, res) => {
|
||||
|
||||
router.delete('/:id', authenticate, (req, res) => {
|
||||
var id = req.params.id;
|
||||
// var hide = req.params.hide;
|
||||
|
||||
let hide = true;
|
||||
|
||||
if (!ObjectID.isValid(id)) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
Todo.findByIdAndRemove(id).then((todo) => {
|
||||
if (!todo) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
if (hide) {
|
||||
Todo.findByIdAndUpdate(id, { $set: { deleted: true } }).then((todo) => {
|
||||
if (!todo) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
res.send({ todo });
|
||||
}).catch((e) => {
|
||||
res.status(400).send();
|
||||
});
|
||||
|
||||
// tools.mylog('DELETED ', todo.descr, todo._id);
|
||||
} else {
|
||||
Todo.findByIdAndRemove(id).then((todo) => {
|
||||
if (!todo) {
|
||||
return res.status(404).send();
|
||||
}
|
||||
|
||||
// tools.mylog('DELETED ', todo.descr, todo._id);
|
||||
|
||||
res.send({ todo });
|
||||
}).catch((e) => {
|
||||
res.status(400).send();
|
||||
});
|
||||
}
|
||||
|
||||
res.send({ todo });
|
||||
}).catch((e) => {
|
||||
res.status(400).send();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user