mongoose deleteone async await return deleted id 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();
});