I have a simple problem, I am trying to return a MongoDB document after a query in my Node.js server :
var coords = [];
coords[0] = req.query.valArray.lng; // client latitude
coords[1] = req.query.valArray.lat; // client longitude
var distanceInKM = req.query.valArray.rangeKM; // the range
//the query that its results i want to return by res.send()
db.Jobs.find( {
$and: [ { {exp: req.query.valArray.exp} },
{ field: req.query.valArray.field }
] } )
My questions are:
- How to return the document according to the
req.query
(exp = query.exp ) and the rest of the params by theres.send()
function. - How to search by the coordination(coords) and the range from the current location
(lng , lat)
, in other words create a radius from the coords that all matching jobs will return as a json.