title: Firebase - Making a homefeed of posts of people you follow (swift)
body: <p>whats the most scalable solution to this? </p>
  
  <pre><code>- posts
      - userID
      - userID
            - randomID
            - randomID
  - followers
      - personB userid
            - personA userid
  - following 
      - personA userid
            - personB userid
  </code></pre>
  
  <p>I have a Database structure like this. so if person A starts following person B he will be put under person B´s ID under "followers". At the same time person B will be put under persons A´s id under "following". </p>
  
  <p>If a person makes a post on the App, it will be posted under "posts" and has a child with the userID of the person who posted (and under there, childs with random ids of different posts they have).</p>
  
  <p>I have tried </p>
  
  <pre><code>let queryRef = self.ref.child("posts/\(userID)")
  
   queryRef?.observe(.childAdded, with: { (snapshot) in
  
      // new post from a friend 
  
  })`
  </code></pre>
  
  <p>I'd have to use this method for every single person the user follows though which would be really slow if there is alot of people who has posted stuff! </p>
  
  <p>Do you guys have any smart scalable solutions to this problem?</p>