title: Test if a data exist in Firebase
body: <p>I would like test if a data exist in Firebase before to add it. But I have a problem with my method: I try to list all data with this Javascript code:</p>
  
  <pre><code>var theDataToAdd = userName;
  var usersRef = new Firebase('https://SampleChat.firebaseIO-demo.com/users/');
  usersRef.on('child_added', function(snapshot) {
     var message = snapshot.val();
     if (message.name == theDataToAdd)
        alert ("exist");
  });
  </code></pre>
  
  <p>But if the user doesn't exist, it will be added before, then my code says that he exists. You will say that is normal because my alert is called only when "child_added", but I don't see how do.</p>
  
  <p>I have also try with the "value" event but my "message.name" is empty.</p>
  
  <p>How can I fix it?</p>