Rumah > Soal Jawab > teks badan
文章Model:
Post.getOneById = function(_id, callback) {
...
db.collection('posts', function(err, collection){
collection.findOne({"_id": new ObjectID(_id)},function(err, doc){
....
}
}
}
路由:
app.get('/p/:_id', function(req, res){
Post.getOneById( req.params._id, function(err, post){
...
}
}
好像这句有问题 {"_id": new ObjectID(_id)}