Im quite new to node and mongodb, but im trying to write a simple API for a monitoring app. I can list out all aps fine through the /aps
call, but /locations
throws a:
process.nextTick(function() { throw err; });
^
TypeError:
cb
is not a function
I have a collection with the following Schema:
ap = {
"name": apname,
"details": [{
"apmodel": apmodel,
"apmac": apmac,
"apipadd": apipadd,
"apclientcount": apclientcount,
"aplocation": aplocation
}]
}
// Get all aps works a charm
router.get('/aps', function(req, res, next){
db.ap_info.find().sort({name: 1}, function(err, aps){
if(err){
res.send(err);
}
res.json(aps);
});
});
But the following does not work:
//Get unique locations with wifi
router.get('/locations', function(req, res, next){
db.ap_info.distinct('details.aplocation', function(err, results){
console.log(results);
});
});
Thing is, when i execute db.ap_info.distinct('details.aplocation')
in mongodb, it works, what am i missing here?