根据自带_id值删除老有问题,javascript collection.remove({_id: ObjectId(id)}, {w:1}, function (err) { db.close() callback(err) }) 提示ObjectId未定义,直接写_id:id 删不掉,id为一个字符串
javascript collection.remove({_id: ObjectId(id)}, {w:1}, function (err) { db.close() callback(err) })
学习是最好的投资!
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
db.collection.remove({"_id":ObjectId(id)});
If the id is a string, you can do this directly
db.collection.remove({"_id":"你的id"});
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
db.collection.remove({"_id":ObjectId(id)});
If the id is a string, you can do this directly