我在Expressjs中有这样的查询:
collection.find({location : {$near: [106.688227,10.774266], $maxDistance: 0.01}},function(e, docs) {
res.json(docs);
});
它运行良好但是当我从请求中获取参数并将其放入查询时,它不起作用:
router.get('/locations', function(req, res) {
var lat = req.param('lat');
var lng = req.param('lng');
var radius = req.param('radius');
var db = req.db;
var collection = db.get('location');
collection.find({location : {$near: [lng,lat], $maxDistance: radius}},function(e, docs) {
res.json(docs);
});
});
我如何将“lng”,“lat”和“radius”替换为查询?
感谢。