title: Listen to changes of all databases in CouchDB
body: <p>I have a scenario where there are multiple (~1000 - 5000) databases being created dynamically in CouchDB, similar to the &quot;one database per user&quot; strategy. Whenever a user creates a document in any DB, I need to hit an existing API and update that document. This need not be synchronous. A short delay is acceptable. I have thought of two ways to solve this:</p>
  <ol>
  <li><h3>Continuously listen to the changes feed of the <code>_global_changes</code> database.</h3>
  <ul>
  <li>Get the db name which was updated from the feed.</li>
  <li>Call the <code>/{db}/_changes</code> API with the seq (stored in redis).</li>
  <li>Fetch the changed document, call my external API and update the document</li>
  </ul>
  </li>
  <li><h3>Continuously replicate all databases into a single database.</h3>
  <ul>
  <li>Listen to the <code>/_changes</code> feed of this database.</li>
  <li>Fetch the changed document, call my external API and update the document in the original database (I can easily keep a track of which document originally belongs to which database)</li>
  </ul>
  </li>
  </ol>
  <p>Questions:</p>
  <ol>
  <li>Does any of the above make sense? Will it scale to 5000 databases?</li>
  <li>How do I handle failures? It is critical that the API be hit for all documents.</li>
  </ol>
  <p>Thanks!</p>