title: Firebase Firestore, query a users friend's posts
body: <p>I am looking create a social-media feed using Firebase. My data is structured like this:</p>
  
  <pre><code>users: {
   uid: {
     ... // details  
    }
  }
  
  friends: { 
    uid: {
      friends: { // sub collection
        fuid: {
           ... // details
       }       
      }
    }
  }`
  
  posts: { 
    postId: {
      postedBy: uid
      ... // details
    }
  }
  </code></pre>
  
  <p>Now I am trying to get the posts from all friends of the user, limit it to the most recent 10 posts, and then create a scrolling directive that queries the next set of 10 posts so that the user doesn't have to query and load posts^N for friends^N on the page load. But I'm not really sure how to query firebase in an effective manner like this, for the user's friends and then their posts. </p>
  
  <p>I have the scrolling directive working, taken from <a href="https://angularfirebase.com/lessons/infinite-scroll-firestore-angular/" rel="nofollow noreferrer">Jeff Delaney's Infinite Scrolling Lesson on AngularFirebase.com.</a> But it only handles the posts (boats in the tutorial) collection as a whole, without selectively querying within that collection (to check if the user is a friend). </p>
  
  <p>The only solution that I could think of was to query all of the user's friends posts, store that in an array, and then chunk load the results in the DOM based on the last batch of posts that were loaded. This just seems like it could be really inefficient in the long-haul if the user has 100's of friends, with 100's of posts each. </p>