Using mongodb and monk. I'm trying to delete a record and I keep on getting the error: Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters in hex format Different code that I have tried:
router.get('/delete/:id', function(req, res) {
var db = req.db;
var uid = req.params.id.toString();
var collection = db.get('usercollection');
collection.remove({"_id":uid}, function(err, result) {
if(result === 0){
res.send("There was a problem delete the information to the database.");
}
else{
res.location("list");
res.send(res.redirect("list"));
}
});
});
module.exports = router;
Here is jade file
List
ul
each event, i in list
li
#{event.id} : #{event.text}
a(href="/delete/#{event._id}") Delete