firebase / geofire-java

GeoFire for Java - Realtime location queries with Firebase
MIT License
670 stars 271 forks source link

Multiple inserts #56

Closed leonardo2204 closed 6 years ago

leonardo2204 commented 7 years ago

Hey guys, A common scenario using GeoFire is:

  1. Save the Geo to a Collection
  2. Grab the key (perhaps the object) and save it to another collection
  3. You're done.

So, the problem that arise is, we can't guarantee the consistency in Firebase, e.g. if some error occurs in any of the steps. In this case, Firebase provides mDatabase.updateChildren(childUpdates);. My question is, what is the best scenario to handle this common situation with GeoFire ?

I was thinking about maybe exposing the updates HashMap as in GeoFire:

Map<String, Object> updates = new HashMap<String, Object>();
        updates.put("g", geoHash.getGeoHashString());
        updates.put("l", Arrays.asList(location.latitude, location.longitude));

Or maybe creating another overloaded method receiving a HashMap, adding the updates to it and calling mDatabase.updateChildren(childUpdates);

Does it make sense ?

vanniktech commented 6 years ago

I don't quite understand what you're trying to achieve. Can you elaborate a bit?

samtstern commented 6 years ago

I believe the request here was to be able to add model data and geo data at the same time as an atomic batch.

samtstern commented 6 years ago

Closing as duplicate of #51