MichaelSolati / geofirestore-js

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

How to query firestore collection when GeoFirestore is used ? #103

Closed patpune closed 4 years ago

patpune commented 5 years ago

As I play with GeoFirestore (which is very cool), the data structure that it creates in firestore is like

(collection-name)

|-"geohash1" 

     |- d: {"my data" dictionary} 

     |- g: "geohash" 

     |- l: geopoint:location 

|-"geohash2" 

       |- d: {"my data" dictionary} 

       |- g: "geohash" 

       |- l: geopoint:location` 

Using the above I am able to locate the places and associate the data. So the library is doing it's job and doing it well. The challenge I have been facing with this is that , in my other panels (non map related) I am also suppose to query name:value pairs associated with "my data" which is now stored as a map. So my question is:

MichaelSolati commented 5 years ago

So, no, currently geofirestore CAN'T do this... However I started working on version 4 which will... However v4 may not be compatible with v3 (that's yet to be seen, and if that is the case I will write a conversion script for people).

patpune commented 5 years ago

@MichaelSolati - Thanks for your response. So then if one needs to query "mydata" will one need to denormalize the "mydata" and keep two copies (in sync) ? When searching by geohash use one collection and when need to query mydata use another one ?

24dev commented 5 years ago

@patpune We do this, and decided to create 2 collections. One with geofirestore data (and nothing else), and one with the full documents. The documents are linked by the same ID.

jerryheir commented 5 years ago

I predict a lot of people will be using this soon. But I also noticed there is no way to do a .where() on the query, the data is not really accessible @MichaelSolati

MichaelSolati commented 5 years ago

@jerryheir I'm not sure what you mean when you say you can't use the .where()

jerryheir commented 5 years ago

Thanks for your quick response @MichaelSolati , I created a small issue for it