Answers for "delete a document from a collection mongoose"

4

mongoose find by and delete

Campground.findByIdAndRemove(req.params.id, function(err){
      if(err){
          res.redirect("/campgrounds");
      } else {
          res.redirect("/campgrounds");
      }
   });
Posted by: Guest on August-10-2020
1

remove everything from mongodb databaase mongoose

await Challenge.deleteMany({})
    await Own.deleteMany({})
    await User.deleteMany({})
Posted by: Guest on August-16-2020

Code answers related to "delete a document from a collection mongoose"

Browse Popular Code Answers by Language