I m trying to select/delete entries from my mongodb via node.js and mongodb-wrapper. I get the id of the entry as a string via a http request. Then I want to delete the entry with the specific id.
app.delete( /posts/:id , function(req, res) {
res.header("Access-Control-Allow-Origin", "*");
db.posts.remove({"_id": req.params.id}, function(err) {
if (err) return res.send(err.message, 500); // server error
res.send(200);
})
res.send("ok");
});
But this is not working. I already tried several ways but nothing deletes the entry. I have red something that I must convert the string into a ObjectId but until now I didn t found anything how to do this via mongodb-wrapper.