MichaelSolati / geofirestore-js

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

How do I access the Geopoint and geohash of a document? #126

Closed namanarora00 closed 5 years ago

namanarora00 commented 5 years ago

The data function returns only the d field of the document. There seems to be no way of getting the geopoint of the document or am I missing something?

MichaelSolati commented 5 years ago

The goepoint and geohash aren't docs intended for you to have access to, geofiretore is designed to wrap the data you give when it inserts it into firestore and return only the data you gave us when you query from it. So it'll only return the d data. If you're looking for the geopoint, it's wherever you stored it originally in your doc/data/d. (Hopefully I was clear here, if not let me know)

namanarora00 commented 5 years ago

Thank you for your response! So the way you're suggesting or the way it was intended to be done in the first place is I have to store the geopoint twice in one document. Once in d field and the other in the l field. Wouldn't it be better if I could access the geopoint stored in the l field itself to remove the redundancy of storing the same data twice?

MichaelSolati commented 5 years ago

My reason for avoiding that is I didn't want to give access to what make geofirestore work under the hood. If the user modifies either the g or l and it doesn't update everything it could negatively impact performance. However I'm open to making the change in a newer version.