title: How to implement infinite scroll with multiple filter on data that get from Firebase in Swift?
body: <p>I'm using Firebase for my iOS application and I'm having trouble implement infinite scroll and filtering data together.</p>
  
  <p><strong>What I need to do is:</strong></p>
  
  <ol>
  <li>Display items with order/filter on multiple property (location, category, status . . .)</li>
  <li>Implement infinite scroll when the user scrolled to bottom of the screen.</li>
  </ol>
  
  <p><strong>I tried to think about some solutions:</strong></p>
  
  <ol>
  <li><p>The first, I think that I'll query the data with the necessary conditions then limit the number of records by use <code>queryLimitedToFirst(N)</code>, and increase N when need to load the next items. But because Firebase can only filter on one property at a time and it's also a waste to reload data. So, I was thinking about the second solution. </p></li>
  <li><p>As approaches are suggested from Frank van Puffelen (<a href="https://stackoverflow.com/questions/26700924/query-based-on-multiple-where-clauses-in-firebase">Query based on multiple where clauses in firebase</a>):</p>
  
  <blockquote>
    <p>filter most on the server, do the rest on the client</p>
  </blockquote>
  
  <p>Yes, exactly like that. I'll execute <code>queryOrderedByKey</code>, <code>queryStartingAtValue</code>, <code>queryEndingAtValue</code> to implement infinite scroll, pull down the remaining data and filter that on client. But there is one problem that is I would not have enough items to display for the user if execute filter on the client.</p>
  
  <p><em>For example: each time run the query, I receive 10 items. After data filtering process on the client, I just left 5 (can be 0) items meet the conditions to display to the user.</em></p>
  
  <p>I don't want this because user may think there is a problem</p></li>
  </ol>
  
  <p><strong>Can I please get some pointers on this? If I didn't structured the data properly, can I also get some tips there?</strong></p>