I've been building a small API in Express and Mongoskin. I added a simple aggregrate geoNear query to respond to params given. The server returns 200 and I get no error. I know that I'm pointing to the right collection and everything, and when I run the query in Mongo's shell it works fine. The code is below:
app.get('/collections/:collectionName/geonear', function(req, res, next) {
req.collection.aggregate([
{
"$geoNear": {
"near": [req.query.lng, req.query.lat],
"distanceField": "distance"
}
},
{
"$sort": {"distance": -1}
}
],
function(e, results) {
res.send(results);
});
});