I edit this todo app and make a multiple topics version of it. Like todos for X, todos for Y, todos for Z...

However i couldn't find a proper way to edit this part :


        if(error) return next(error);
        if(!task) return next(new Error('Task is not found'));

        //if there's data, we store it in the request and proceed to the next middleware:
        req.task = task;
        return next();

Because instead of tasks , i have now xtopic,ytopic,...

So if i add a task to Y,Z, or another topic, it should restored in that part.
But when i try to mark "done" a task in Y, or Z, it creates an error.
How can i restore all tasks by its topic?

This is how it looks like :