How to get the key of a Firebase Object
<p>How can I get the Key of a Firebase object without using snapshot?</p>

<p>I have done the research below.</p>

<p>Using the code:</p>

<pre><code>var ref = new Firebase('https://johnsoncompany.firebaseio.com/people')

var firstPerson = ref.orderByChild("first").limitToFirst(1);

var key = $firebaseObject(firstPerson);
</code></pre>

<p>..I get the object below:</p>

<pre><code>{  
   "5":{  
      "first":"Jennifer",
      "last":"Robert",
      "mobile":"121 364 135",
   }
}
</code></pre>

<p>Firebase had given my object the key "5" since the data is contained in an array of values. This was the 6th value.</p>

<p>The challenge is that in-order to get the value "Jennifer", I have to know that the key is "5".</p>

<p>I will then use the code:</p>

<pre><code>var firstPerson = $firebaseObject(ref.child('5'))

var firstName = firstPerson.first; //Returns Jennifer
</code></pre>

<p>I know I can use the code below to get the key '5':</p>

<pre><code>    ref.orderByChild("first").limitToFirst(1).once("child_added", function(snapshot) {
        alert(snapshot.key());
    }); 
</code></pre>

<p>The challenge is that there is a delay before it returns the key. This results to an malfuctioning app.</p>

<p>Is there a way I can get the key without snapshot</p>

<pre><code>ref.orderByChild("first").limitToFirst(1).key(); //This doesn't work
</code></pre>