title: Query users in Firebase to check if username exists during sign up process
body: <p><strong>Question</strong></p>
  
  <p>How do I check if a username already exists during the user sign up process? </p>
  
  <p><em>I don't know how to query Firebase to determine if a specific value exists.</em> </p>
  
  <hr>
  
  <p><strong>Background</strong></p>
  
  <p>Firebase structure:</p>
  
  <pre><code>Users
      0BBfrF1vVBXXxNxeVMes9MFkYNJ3
      name: "SAM"
  
      0oU9sf7CZxaDBx03t87lqTrv9UM2
      name: "JACK"
  
      IsXEqXov0obuwl1WOrHhCbfdfEo1
      name: "JEREMY"
  </code></pre>
  
  <p>In the code below:</p>
  
  <ul>
  <li>I attempt to check if value <code>usernameField</code> exists in: <code>users\userID\name</code></li>
  <li><code>child(userID)</code> doesn't retrieve anything</li>
  </ul>
  
  <p>_</p>
  
  <pre><code>let username = self.usernameField.text
  
          let userRef = ref.child("Users").child(userID).child("name")
  
          userRef.observeEventType(.Value, withBlock: { snapshot in
  
              if snapshot.value!.isEqual(username) {
  
                  print("snapshot exists")
  
              } else {
  
                  print("snapshot doesnt exist")
  
              }
  
  
              userRef.removeAllObservers()
  
              }, withCancelBlock: { error in
  
                  print(error)
  
          })
  </code></pre>