title: Firebase query 2 levels deep without full reference swift
body: <p>Is there a way to query firebase data without knowing the whole reference path? I need to be able to pull data from one user's profile into another based off of the <em>solution number</em> value.</p>
  
  <p>Here is a picture of my data structure</p>
  
  <p><a href="http://i.stack.imgur.com/UI1IH.png" rel="nofollow">data structure setup</a></p>
  
  <p>I won't have access to another user's UID when I'm trying to send info. Is there any way around this or am I going to have to restructure my data?</p>
  
  <p>This is my current query method, I just think the for loop might be bad practice</p>
  
  <pre><code>// MARK: - Search for trainees
  func searchForTrainees() {
  
      self.ref.child("users").observeSingleEventOfType(.Value, withBlock: { snapshot in
  
          if snapshot.value! is NSNull {
  
          } else {
  
              if let users = snapshot.value! as? JSONDictionary {
  
                  for user in users {
  
                      let userUID = user.0
  
                      if let userInfo = user.1 as? JSONDictionary {
  
                          if let uplineSolutionNumber = userInfo["upline_solution_number"] as? String {
  
                              if uplineSolutionNumber == self.currentUser?.solution_number {
  
                                  self.syncUserData(userUID)
  
                              }
                          }
                      }
                  }
              }
          }
      })
  }
  </code></pre>
  
  <p>If there is a more efficient way to do this please let me know</p>