mrdishant / flutter_geofire

A Flutter plugin to get the realtime updates of places nearby usinf Firebase GeoFire.
MIT License
23 stars 27 forks source link

Add GeoFire keys and Lat/Lng values to existing Firebase Node Children #14

Open GrahamDi opened 4 years ago

GrahamDi commented 4 years ago

@mrdishant

I have a need to select a group of app user profiles by their proximity to a given location. The size of the user profile list can be in the hundreds of thousands and I need to select a subset of these using their location. The size of the subset would be around one to two thousand user profiles.

I can achieve this with the current flutter_geofire package by querying the location on a certain radius, retrieving the individual userids from the keylist returned and then calling Firebase RTDB on each of these userids to retrieve the necessary additional information. Reading one to two thousand individual user profile records is obviously inefficient though.

I would prefer to be able to additionally store the GeoFire hash key and the lat/lng on each user record and execute the query, with the desired radius, against the users db node as a once-off call ie. no listener. In this way I can retrieve all the relevant users in one Firebase call and in one snapshot, and put the results in a local list of user profiles.

The GeoFire query listener would still operate on the GeoFire database node as normal and trigger on any changes of locations, which can then be used to update the local user list and the UI.

Hope this clear?

Is this something you would consider, or can you suggest a better or alternative solution?