How do I remove a document using its _id ?
I've tried all the googled options for remove and none of them actually delete the document.
Menu is my model name my req.payload.id is a string version of the _id .
My last attempt was to try
these three was of defining id, but none work
id = req.payload.id
id = {"_id": req.payload.id};
id = mongoose.Types.ObjectId(req.payload.id);
Menu.findByIdAndRemove(id,function(err,doc){
if(err){
}
else {
}
});
I've also tried other things like findbyid first, the calling remove(), but those didn't work either.
I'd appreciate any tips on simply delete a document by _id .
Thanks, Don