I'm trying to implement a simple backend todo list using mongoose, mongo, express and ejs.
I'm stuck while adding a "delete item from mongo using mongoose by pressing the html checkbox"
The code I'm trying to implement happens between line 76 and 86 of "app.js":
app.post('/delete', (req, res) => {
    // DELETE CHECKED ITEM ON list.ejs FORM USING ITS _id
    const checkedItemId = req.body.checkbox;
    console.log(checkedItemId);
    Item.findByIdAndRemove(checkedItemId, (err) => {
        if (!err) {
            console.log('Successfully deleted checked item');
            res.redirect('/');
        }
    });
});
Once I check the checkbox the item is not deleted and remain visible, also if I check the checkbox twice the ".findByAndRemove" funcion seems to work and gives me "Succesfully Deleted" but once I check the mongo collection with "db.items.find()" the item is still there.
the full project can be found on:
https://github.com/emanuelefavero/mongoose-todolist.git
Please remember to start the mongo server before launching the app, also run "npm i" inside the project directory to install required npm packages after downlading the project.
Thanks.