title: firebase realtime database find node by child value
body: <p>I have the following structure: </p>
  
  <pre><code>root
    -LKMsdf2_Qxbwtv4238D
       details
         uid: john
  
    -YKMWrmj_QxbwtvSBM5A
       details
         uid: tony
  
    -R45Wrmj_Qxbf321BMd4
       details
         uid: karina
  </code></pre>
  
  <p>How can I find the ref key under 'root' by its uid: </p>
  
  <p>e.g: by uid:karina I need to get the ref key -R45Wrmj_Qxbf321BMd4</p>
  
  <p>is there a way to use some wildcard like /root/{recordid}/details/uid or something?</p>
  
  <p><strong>======== Thanks for the hints! ====  here is my final solution ================</strong></p>
  
  <pre><code>findEntry = function(targetUid) {
  var entriesRef = db.ref('root');
  return entriesRef.once('value')
      .then((snapshot)=&gt;{
          var id = []; // found id
  
          snapshot.forEach((childSnapshot)=&gt;{
              var childKey = childSnapshot.key;
              var childData = childSnapshot.val();
              var found = (childData.uid === targetUid);
              if (found) {
                  console.log('Found for uid:' + targetUid  + ': ' + childKey);
                  id = childKey;
              }
              return found; // true - breaks the forEach, false - continue
          });
      if (!id) {
          console.log('Not Found for uid:' + targetUid);
      }
      return id;
    });
  </code></pre>
  
  <p>}</p>