I have a database managed solely via iOS of the following format in Firebase:
hotels/
hotel1/
guests/
*[RandomID]:guest1
[RandomID]:guest2
[RandomID]:guest3
location/
address
...
hotel2/
guests/
[RandomID]:guest3
[RandomID]:guest4
location/
address
...
hotel3/
guests/
location/
address
...
hotel4/
guests/
[RandomID]:guest4
[RandomID]:guest5
location/
address
...
hotel5/
guests/
[RandomID]:guest3
location/
address
...
...
My goal is to run a Swift command to return the set of 'hotels' that have a given guest. For example, checking for guest3 should return hotels 1, 2, and 5 with associated data. Something along the lines of this would typically work:
Query filterQuery = databaseReference.orderByChild("type").equalTo(true);
but unfortunately, it doesn't seem like there is an equivalent to the equalTo
command in the iOS documentation. What is the best way to accomplish this task in the bounds of the iOS Firebase library then?
*The random IDs are generated automatically when the guest entry is inserted into the guests dictionary, as per this blog post: https://firebase.googleblog.com/2014/04/best-practices-arrays-in-firebase.html. It seems unintuitive, but apparently uniqueness must be ensured by assigning each element a unique ID generated at insertion time.