Doubt with Findone in Angularjs using Mongojs error at search time

Asked

Viewed 41 times

1

Hello I am trying to make a search in the bank with this code using the findOne of mongojs, follows 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) back the correct id but when using the function of findOne of this mistake:

"567a16ba28dee028f4a8ad78 <-- id log console

Typeerror: Cannot read Property 'findOne' of Undefined at /Users/Michel/Documents/Angularprojects/Rodrigobranaslistatelefonica/server.js:48:12"

  • I already checked everything in the bank Collection everything correct the id also exists

  • The model is being loaded before this controller?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.