MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.
https://geofirestore.com
MIT License
505 stars 58 forks source link

Set an attribute to execute the query on #50

Closed Wilker-uwu closed 5 years ago

Wilker-uwu commented 5 years ago

Hello, i really like this project for being useful, but there is something i've been stuck on and it's been a bit confusing too.

The current situation is: i connect to my collection, i make the query with range, coords and an attribute "name" to search on. What i get is an error from Firebase asking for me to create an index. The index currently sets an attribute g in ascending order to make the index. It took me some time to assume that this is the attribute used for the query (because i am really dumb reading the documentation sometimes, i'm sorry (also about the d. attribute >-<) :/)

The problem comes when i need it to query the coordinates in the documents with an attribute called coordenadas (portuguese for "coordinates").
How would i be able to use a custom attribute to query the coordinates on?

If this feature is not existent yet, i think it would be something really useful to implement.

thank you for the attention =^-^=

MichaelSolati commented 5 years ago

When you encode a document you are able to set the field in your document for the location. So instead of coordinates you can tell geofirestore to use coordenadas. However for the query you don't need that, as we query on the g field.

I guess if your question is how do you encode a document into geofirestore using a custom field like coordenadas it would look like this....

geoFirestore.add({ coordenadas: new firebase.firestore.GeoPoint(37.79, -122.41)}, 'coordenadas');

Let me know if that helps, or answers the question!

Wilker-uwu commented 5 years ago

Thank you, that should help ^-^

(sorry for the late reply though)