Answers for "delete field in 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
2

mongoose delete property

User.collection.update({_id: user._id}, {$unset: {field: 1 }});
Posted by: Guest on November-01-2020

Browse Popular Code Answers by Language