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

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

répondre à tous(0)
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!