title: Designing a Firebase based scalable feed model
body: <p><strong>Question :</strong></p>
  
  <p>How to design a social network "feed" with Firebase as backend, that scales ?</p>
  
  <p><strong>Possible answers :</strong></p>
  
  <p>"MVP" solution is to design a <code>feeds</code> root child, one for each user, and append any new post from the followed user in every follower's feeds.</p>
  
  <pre><code>users
    user1
      name: bob
    user2
      name: alice
      follows: 
        user1: true
  
  posts
    post1
       author: user1
       text: 'Hi there'
  
  feeds
    user2
      post1: true
  </code></pre>
  
  <p>This works well, and is demoed in the <code>Firefeed</code> project. But it does not scale well : if Katy Perry wants to post something, her mobile phone will have to write to millions of feed.</p>
  
  <p>Hence the solution reported in <a href="https://stackoverflow.com/questions/27544325/firebase-data-structure-is-the-firefeed-structure-relevant">this SO question</a> to delegate this operation to a server based process. </p>
  
  <p>My problem is, Firebase is a "no-backend" solution, and this is the main reason why I use it, so I'd like to make sure there is absolutely no chance of implementing this feature without a server.</p>
  
  <p>What if the <code>feeds</code> child is removed in the above schema ?</p>
  
  <p>Then do this :</p>
  
  <pre><code>baseRef.child('posts')
         .orderBy('author')
         .whereIn(baseRef.child('users/user2/follows').keys())
  </code></pre>
  
  <p>Unfortunately, <code>whereIn</code> does not exists in Firebase API, nor subqueries :(</p>
  
  <p>Any other model structure possible without the need of a server ?</p>
  
  <p>Thanks</p>