mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-29 08:07:48 +01:00
add offline support
This commit is contained in:
@@ -24,7 +24,8 @@ router.post(
|
||||
'/',
|
||||
asyncHelper(async (req, res) => {
|
||||
const { name } = req.body;
|
||||
const newList = new TodoList({ name, user: req.user.id });
|
||||
const { id } = req.body || mongoose.Types.ObjectId();
|
||||
const newList = new TodoList({ name, user: req.user.id, _id: id });
|
||||
await newList.save();
|
||||
res.json({ success: true, data: newList.toJson() });
|
||||
}),
|
||||
|
||||
@@ -26,7 +26,8 @@ router.post(
|
||||
asyncHelper(async (req, res) => {
|
||||
const { listId } = res.locals || req.body;
|
||||
const { text } = req.body;
|
||||
const todo = new Todo({ text, list: listId, user: req.user.id });
|
||||
const { id } = req.body || mongoose.Types.ObjectId();
|
||||
const todo = new Todo({ text, list: listId, user: req.user.id, _id: id });
|
||||
await todo.save();
|
||||
res.json({ success: true, data: todo.toJson() });
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user