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
– michelpm1
The model is being loaded before this controller?
– Liw. S.