我很难使用用户的坐标(最大距离)来过滤文档。
我的请求如下:
app.post('/item', checkAuth, function(request, response) {
var location = request.body.location;
var distance = request.body.distance;
Item.find( { "location": {
$near: { $geometry: { type: "Point",
coordinates: [location.longitude, location.latitude] },
$maxDistance: distance
}
} }, function(err, items) {
if (err) {
response.status(500).send({error: err});
} else {
response.send({items : items,
message: 'Fetching items successful'
});
}
});
});