mongoose find and delete by id async code example
Example: findbyid and delete mongoose await
Subscriber.findByIdAndRemove(subscriberId)
.then(() => {
res.locals.redirect = "/subscribers";
next();
})
.catch(error => {
console.log(`Error deleting subscriber by ID: ${error.message}`);
next();
});