Search code examples
iosfirebasegeofire

GeoFire and Firebase Query


I'm a bit confused on the proper way to query Firebase with GeoFire results.

Reading the directions for GeoFire, I should keep locations and user data separate in the tree. So I have the following:

-location
     - userID
          - g
          - l
            - 0:lat
            - 1:long

- user
    -userID
       - ...

Using a Geofire query, I have an array of userIDs that are nearby. This is where I get confused, I don't see any methods for Firebase to query an Array of items. I would like to retrieve the user data for every user in the array.

I could loop through the list and make multiple requests, but that seems to be an inefficient way to get the desired results.


Solution

  • I don't see any methods for Firebase to query an Array of items. I would like to retrieve the user data for every user in the array.

    There indeed isn't a call for that.

    I could loop through the list and make multiple requests, but that seems to be an inefficient way to get the desired results.

    While it may seem inefficient, it actually is not. The reason for this is that Firebase is quite efficient at loading multiple items, since it retrieves all of them over the same web socket and pipelines the request.

    For a more elaborate explanation, see Speed up fetching posts for my social network app by using query instead of observing a single event repeatedly