title: Managing unread messages in firebase chat
body: <p>I'm building real time chat, very similar with skype one. I use firebase as backend and angularfire on client side.
  Basically, all things are look clear, but I've stuck with one thing - showing of unread messages count.</p>
  
  <p>App uses very simple Firebase design: 2 or more users can chat in a "room" - root collection with unique name. Chat message except of text can contain "metadata" - sender id, timestamp, etc.</p>
  
  <p>Simply, I need an emulation of this pseudo-code:</p>
  
  <p><strong>room.messages.where({ unread: true }).count()</strong></p>
  
  <p>For now, according to <a href="https://www.firebase.com/docs/faq.html" rel="noreferrer">this</a>, (Can I count the children at a location without retrieving the actual child data?) and <a href="https://stackoverflow.com/questions/15148803/in-firebase-is-there-a-way-to-get-the-of-children-of-a-node-w-out-loading-all">this</a> I'm trying to manage unread messages count per room by transactions and reset count when viewed. But it is very tricky part, and I'm curious, do we have any recommended approach here, which can reduce amount of job?</p>