title: Firebase : How to structure group post with likes?
body: <p>This are what I have tried so far. </p>
  
  <p><strong>Group Posts</strong></p>
  
  <pre><code>{
      "group_posts":{
          "group_push_key":{
              "foo":"bar",
              "biz":"baz",
          }
      }
  }
  </code></pre>
  
  <p><strong>Likes</strong></p>
  
  <pre><code>{
      "group_likes":{
          "group_push_key":{
              "user_uid1":true,
              "user_uid2":true,
              "user_uid3":true
          }
      }
  }
  </code></pre>
  
  <p>By using this setup, I could detect if the user already liked a post by querying from ref <code>group_likes/{group_push_key}/{user_uid1}</code> equal to <code>true</code>. </p>
  
  <p>My problem with this setup is the tracking of like count. I sure can do <code>snap.numChildren()</code> but this only returns the count of the snapshot returned. Is there an existing/standard way of doing this <code>post</code>x<code>likes</code> relationship in firebase? </p>
  
  <p><strong>PS</strong></p>
  
  <p>I was thinking of having a node server which will watch every <code>child_added</code> or <code>child_removed</code> event then change the like count accordingly.</p>