文章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)}
ringa_lee