title: How to keep Firebase in sync with another database
body: <p>We need to keep our <code>Firebase</code> data in sync with other <code>databases</code> for <code>full-text search</code> (in <code>ElasticSearch</code>) and other kinds of queries that <code>Firebase</code> doesn't easily support.</p>
  
  <p>This needs to be as close to real-time as possible, we can't just export a nightly dump of the <code>Firebase JSON</code> or anything like that, aside from the fact that this will get rather large.</p>
  
  <p>My initial thought was to run a <code>Node.js</code> client which listens to <code>child_changed</code>, <code>child_added</code>, <code>child_removed</code> etc... events of all the main lists, but this could get a bit unweildy and would it be a reliable way of syncing if the client re-connects after a period of time?</p>
  
  <p>My next thought was to maintain a list of "items changed" events and write to that every time an item is created/updated, similar to the <a href="https://github.com/firebase/firebase-work-queue" rel="noreferrer">Firebase work queue</a> example. The queue could contain the full path to the data which has changed and the worker just consumes that and updates the local database accordingly.</p>
  
  <p>The problem here is every bit of code which makes updates has to remember to write to this queue otherwise the two systems will get out of sync. Some proxy code shouldn't be too hard to write though.</p>
  
  <p>Has anyone else done anything similar with any success?</p>