Q: mongodb-wrapper and ObjectId of an entry 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.

A: By using: {"_id": req.params.id} you are querying for a string rather than an objectId. You need to create an ObjectId from the string to use it:
var ObjectID = require('mongodb').ObjectID;
var oid = new ObjectID(req.params.id);

be aware that this will throw an error if the data in req.params.id can not be converted to a valid ObjectID.
