title: Sequential unique IDs for PouchDB
body: <p><a href="https://pouchdb.com/" rel="noreferrer">PouchDB</a> best-practice recommendation is to use <code>PUT</code> instead of <code>POST</code> for creating a new document (analogous to a row in an rdbms) primarily because the latter generates a random ID that makes it inefficient for subsequent sorting of the data. <code>PUT</code>, on the other hand, requires providing a user-generated, unique ID. </p>
  
  <p>I am a bit puzzled that PouchDB doesn't seem to provide this functionality out-of-the-box. So, what is the best way to generate a unique, sequential ID (analogous to PostgreSQL's sequence)? I could use something analogous to <code>maxID</code>, but the main issue, in my view, is to ensure no one else inserts a record between when I determine the maxID and when I actually succeed in inserting a record.</p>
  
  <p>Suggestions?</p>