delete a document from a collection mongoose code example
Example 1: mongoose find by and delete
Campground.findByIdAndRemove(req.params.id, function(err){
if(err){
res.redirect("/campgrounds");
} else {
res.redirect("/campgrounds");
}
});
Example 2: remove everything from mongodb databaase mongoose
await Challenge.deleteMany({})
await Own.deleteMany({})
await User.deleteMany({})