title: Firebase orderByChild query not returning ordered results
body: <p>I am trying to use the Firebase <code>orderByChild()</code> function per the <a href="https://www.firebase.com/docs/web/guide/retrieving-data.html" rel="nofollow noreferrer">documentation example</a> but the queries are not coming back filtered or sorted.</p>
  <p>Here is the sample data structure:</p>
  <pre><code>&quot;notifications&quot;: { 
    &quot;001&quot;: { 
      &quot;member_id&quot;:      &quot;abc123&quot;,
      &quot;created_at&quot;:     1424357680681,
      &quot;new&quot;:            true,
      &quot;first_name&quot;:     &quot;Jon&quot;,
      &quot;last_name&quot;:      &quot;Snow&quot;,
      &quot;message&quot;:        &quot;likes your photo&quot;
    },
    &quot;002&quot;: { 
      &quot;member_id&quot;:      &quot;abc456&quot;,
      &quot;created_at&quot;:     1424357680681,
      &quot;new&quot;:            true,
      &quot;first_name&quot;:     &quot;Clark&quot;,
      &quot;last_name&quot;:      &quot;Kent&quot;,
      &quot;message&quot;:        &quot;likes your comment&quot;
    }
  }
  </code></pre>
  <p>When a user logs in, I want to query the notifications hash for only the notifications with a <code>member_id</code> that matches the current user's id.</p>
  <p>I have tried both versions with and without the &quot;child_added&quot;.</p>
  <p>Option A:</p>
  <pre><code>  ref.orderByChild(&quot;member_id&quot;).equalTo(memberId);
  </code></pre>
  <p>Option B:</p>
  <pre><code>  ref.orderByChild(&quot;member_id&quot;).equalTo(memberId)
      .on(&quot;child_added&quot;, function(data) { 
         console.log(&quot;new child id = &quot; + data.key());
      });
  </code></pre>
  <p>When I query the notifications hash, the query returns an array of all of the notifications. They are neither limited to the <code>member_id</code> of the current user, nor sorted by <code>member_id</code>. (I can delete the member_id key entirely and the notification will still be returned).</p>
  <p>I can always filter the returned array by <code>member_id</code> in-app, but I would really like to get the query working per the documentation.</p>
  <p>Any help is appreciated!</p>