title: Alternatives to Firebase query by value with arrays
body: <p>I'm trying to figure out how to mimic querying by value with an array, but having issues as the data loses its ordering if each query by value is done individually. </p>
  
  <p>Let's say the database has the following format:</p>
  
  <ul>
  <li>postID
  
  <ul>
  <li>userID</li>
  <li>datePosted</li>
  </ul></li>
  </ul>
  
  <p>And on the client side, I have an array of userIDs:
  [id1, id2, id3]</p>
  
  <p>I want to sort postID's by datePosted, query by value where the userID equals one of the id's in the array. I then want to query the first 5 posts. 
  So, this should get a total of at most 5 of the most recent posts from those users.</p>
  
  <p>I've read that you are not able to query by value with an array, meaning this would have to be separated into single queries for each userID (such as <a href="https://stackoverflow.com/questions/29560088/firebase-equivalent-to-sql-where-in">firebase equivalent to sql where in ()</a> suggests). However, if I were to do that, I'd no longer be able to correctly sort by datePosted between posts from different users and would have to download ALL posts to be able to sort and get the first 5.</p>
  
  <p>In essence, I'm trying to accomplish:
   <strong>ref.queryOrderedByChild("datePosted").queryEqualToValue(array, "userID").queryLimitedToFirst(5)</strong></p>
  
  <p>Anyone ran into this kind of problem before? Would appreciate any suggestions!</p>