You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello guys,
I am having issues with using flask-mongoalchemy to query my database and get results that are close to the longitude and latitude I passed.
My Model:
class Event(db.Document):
meta = {
'indexes': [
("*location.coordinates", "2dsphere")
]
}
When an event is created this is how the document is meant to look like:
{
"address": "Surulere",
"end_time": "2019-10-13T00:00:00",
"location": {
"coordinates": [
-119.3996898,
19.6255545
],
"type": "Point"
},
"name": "Amazonss__",
"start_time": "2019-10-12T00:00:00",
"user_id": "3b15b5f9d6d1ab93d14db52cabe6ac",
"uuid": "baa75b69047369a48342e6939c56d3"
}
And My Code for Querying is:
event = Event.query.filter({"location" :
{ "$near" :
{
"$geometry" : {
"type" : "Point",
"coordinates" : [longitude, latitude] },
"$maxDistance" : 4000
}
}
}).first()
The text was updated successfully, but these errors were encountered:
Hello guys,
I am having issues with using flask-mongoalchemy to query my database and get results that are close to the longitude and latitude I passed.
My Model:
class Event(db.Document):
meta = {
'indexes': [
("*location.coordinates", "2dsphere")
]
}
When an event is created this is how the document is meant to look like:
{
"address": "Surulere",
"end_time": "2019-10-13T00:00:00",
"location": {
"coordinates": [
-119.3996898,
19.6255545
],
"type": "Point"
},
"name": "Amazonss__",
"start_time": "2019-10-12T00:00:00",
"user_id": "3b15b5f9d6d1ab93d14db52cabe6ac",
"uuid": "baa75b69047369a48342e6939c56d3"
}
And My Code for Querying is:
event = Event.query.filter({"location" :
{ "$near" :
{
"$geometry" : {
"type" : "Point",
"coordinates" : [longitude, latitude] },
"$maxDistance" : 4000
}
}
}).first()
The text was updated successfully, but these errors were encountered: