firebase / geofire-js

GeoFire for JavaScript - Realtime location queries with Firebase
MIT License
1.45k stars 345 forks source link

Update object one node #11

Closed arthuryeti closed 10 years ago

arthuryeti commented 10 years ago

I would like to update a node with new object, but the current method to do that is only for update location attributes of point, can we do something to improve that ?

jwngr commented 10 years ago

Hey @Atu - thanks for opening an issue on GeoFire. Version 2.0.0 of the API is getting released next Monday and it brings a brand new API which should make it much easier to use. With the new API, you should structure your data like this:

/locations
  /key1
    /name: "Best Buy"
    /city: "San Francisco"
    /...
  /key2
    /name: "McDonald's"
    /city: "Sao Paulo"
    /...

You can then add each location to GeoFire by doing geoFire.set("key1", [key1Latitude, key1Longitude]), geoFire.set("key2", [key2Latitude, key2Longitude]), etc. If the key's location changes, update GeoFire by calling set() again with the same key and the updated latitude, longitude pair. If the key's data changes, update the location data in your Firebase at /locations/<key>/.

Having this separation between where your geolocation data is stored (GeoFire) and where your key's data is stored (somewhere else in Firebase, in this case at /locations/) makes it much easier to use GeoFire 2.0.0.

Take a look at the new version once it comes out on Monday and feel free to re-open this issue if you've got more questions!