根据自带_id值删除老有问题,javascript
collection.remove({_id: ObjectId(id)}, {w:1}, function (err) {
db.close()
callback(err)
})
提示ObjectId未定义,直接写_id:id 删不掉,id为一个字符串
高洛峰2017-04-25 09:03:59
Read the readme document of the official module,
Need to first var ObjectID = require('mongodb').ObjectID;
Then use collection.findAndRemove({_id: new ObjectID(id)}) to do this
怪我咯2017-04-25 09:03:59
If the id is a string, you can do this directly
db.collection.remove({"_id":"你的id"});