Doubt with FindOne in AngularJS using MongoJS error when searching

1

Hello, I'm trying to do a search on the bank with this code using the mongojs findOne, follow code:

 app.get('/detalhesContato/:id', function(req, res){
    var id = req.params.id;
    console.log(id);
    db.contatos.findOne({_id: mongojs.ObjectId(id)}, function(err, doc)    {
     console.log(err);
      res.json(doc);

});

console.log(id) returns the correct id but at the time of using the findOne function of this error:

  

"567a16ba28dee028f4a8ad78 < - id console log

     

TypeError: Can not read property 'findOne' of undefined       at /Users/Michel/Documents/AngularProjects/RodrigoBranasListTelefonica/server.js:48:12 "

    
asked by anonymous 05.02.2016 / 21:09

0 answers