Answers for "mongoose delete all documents"

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
0

clean collection mongoose

await Model.deleteMany();
Posted by: Guest on December-26-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 "mongoose delete all documents"

Browse Popular Code Answers by Language