Am very new to mongodb and golang. I have a collection named \"myplace\" It has the following fileds place_name, city, latitude, longitude. My question is user in some place and
This link might help you https://github.com/mendrugory/Airports
MongoDB query (python)
def get_closest_airports(lonlat, limit=10):
"""
Using a raw query it returns the "limit" closest airports.
:param latlon list:
:return list of airports:
"""
return Airport.objects(
__raw__={"loc": {"$near": {"$geometry": {"type": "Point", "coordinates": lonlat}}}}).limit(limit)
json structure is as following
{"city": "Goroka", "tz": "Pacific/Port_Moresby", "name": "Goroka", "dst": "U", "loc": {"type": "Point", "coordinates": [145.391881, -6.081689]}, "country": "Papua New Guinea", "iata/faa": "GKA", "altitude": 5282.0, "icao": "AYGA", "timezone": 10.0, "id": 1}