marcello3d/node-mongolian — Issue #81: Cannot remove using ObjectID
Author: demian85
Created: 2012-01-23 19:21:49+00:00
State: open

Please explain why I cannot remove an object by its id.

var util = require('util'),
Mongolian = require('mongolian');

var ObjectId = Mongolian.ObjectId ;
var db = new Mongolian('mongo://localhost/nsmetrics');

var collection = db.collection('proxy');
collection.find().toArray(function(err, res) {
console.log(res.length);
collection.remove({_id: new ObjectId(res[0]._id.toString())}, function(err) {
if (err) throw err;
db.server.close();
});
})

That always prints the same length. I still don't know how to use that damn ObjectID.

Thanks.