Answers for "mongoose find and delete"

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

delete document mongoose

Tank.deleteOne({ size: 'large' }, function (err) {
  if (err) return handleError(err);
  // deleted at most one tank document
});
Posted by: Guest on December-12-2019
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 find and delete"

Browse Popular Code Answers by Language