Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mongodb geospetial query doesnt work #13

Closed
Lozovaca opened this issue Aug 10, 2021 · 10 comments
Closed

Mongodb geospetial query doesnt work #13

Lozovaca opened this issue Aug 10, 2021 · 10 comments

Comments

@Lozovaca
Copy link

Hi,
i am trying to use mongodb geospetial query with sanic-motor.

Find with no arguments runs well and my query works in MongoDB Compass.
My query : await DataPoint.find({"location.cordinates": { '$nearSphere' : {'$geometry': { type: "Point", 'coordinates': [20.44974230, 44.8772 ] },'$minDistance': 0,'$maxDistance': 80}}})

Can you help me? I can't solve it.
slika1

Thanks in advance,
Petar

@medvedodesa
Copy link

medvedodesa commented Aug 11, 2021 via email

@Lozovaca
Copy link
Author

Thank you for your response, but i still can't get what is wrong with my query i think this package doesn't have support for this type of queries.

@lixxu
Copy link
Owner

lixxu commented Aug 17, 2021

did you miss quotes for type? `{ type: "Point", 'coordinates': [20.44974230, 44.8772 ] }

@Lozovaca
Copy link
Author

Yes, i changed that but it still doesn't change anything. Your package helped me a lot, i managed to send data to mongo_db trough Sanic, and now i send qeospetial queries trough Django.

@lixxu
Copy link
Owner

lixxu commented Aug 17, 2021

you need use new version sanic.

@bolorundurovj
Copy link

bolorundurovj commented Aug 23, 2021

@lixxu @Lozovaca Please where can i get a comprehensive documentation. Also, how do i pass filters with find query?

@lixxu
Copy link
Owner

lixxu commented Aug 23, 2021

@bolorundurovj
Copy link

https://sanicframework.org/en/guide/basics/request.html#arguments

https://github.com/lixxu/sanic-motor/blob/9e61feab8b5fdd61040595e37e4e72f63e8b9085/sanic_motor/init.py#L247

https://motor.readthedocs.io/en/stable/api-asyncio/asyncio_motor_collection.html

sanic-motor only adds some sanic related args/kwargs, others keeps the same as motor. Check the source code please.

@lixxu When i try this violations = await Violation.find({'speed': {'$gt': 5}}) i get this error: AttributeError: 'dict' object has no attribute 'args'

@lixxu
Copy link
Owner

lixxu commented Aug 25, 2021

have you updated sanic to new version?

@lixxu
Copy link
Owner

lixxu commented Dec 27, 2021

closed as long time feedback.

@lixxu lixxu closed this as completed Dec 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants