MongoDB根据id查询问题
ringa_lee
ringa_lee 2017-04-22 08:56:11
0
0
585

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

ringa_lee

membalas semua(0)
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan