title: More efficient way to retrieve Firebase Data?
body: <p>I have a hierarchical set of data that I want to retrieve information from Firebase. Below is how my data looks:<img src="https://i.stack.imgur.com/6OVI1.png" alt="enter image description here"></p>
  
  <p>However, my issue is this: Upon looking at how the data is structured, when I want to grab the <code>name</code> or <code>object id</code> of an <code>attendee</code>, I have to perform the following code:</p>
  
  <pre><code>func getAttendees(child: NSString, completion: (result: Bool, name: String?, objectID: String?) -&gt; Void){
      var attendeesReference = self.eventsReference.childByAppendingPath((child as String) + "/attendees")
  
      attendeesReference.observeEventType(FEventType.ChildAdded, withBlock: { (snapshot) -&gt; Void in
  
          //Get the name/object ID of the attendee one by one--inefficient?
          let name = snapshot.value.objectForKey("name") as? String
          let objectID = snapshot.value.objectForKey("objectID") as? String
          if snapshot != nil {
              println("Name: \(name) Object ID: \(objectID)")
              completion(result: true, name: name, objectID: objectID)
          }
  
          }) { (error) -&gt; Void in
              println(error.description)
      }   
  }
  </code></pre>
  
  <p>Now this goes through every attendee child and grabs the name and object id one by one. When the function completes, I store each value into a dictionary. Upon doing so, this function is called multiple times and can be very slow especially when going to/from a database so many times. Is there a more efficient way to do this? I have tried to look into <code>FEeventType.Value</code> but that seems to return everything within the <code>attendees</code> child, when all I really want are the <code>name</code> and <code>objectID</code> of each <code>attendee</code> stored into some sort of dictionary. Any help would be appreciated. Thanks!</p>