title: query for range of consecutive values mongo
body: <p>I have a document with a <code>number</code> field. A process adds those documents whose <code>number</code> value is not in the collection, but first, it checks if a document with that <code>number</code> exists. </p>
  
  <p>Consider a collection of documents with <code>number</code> from 0 to 234, <code>number</code> from 653 to 667 and <code>number</code> from 10543 to 22000. Gaps exist for <code>number</code> from 235 to 652 and 668 to 10542 whose documents need to be imported.</p>
  
  <p>Is it possible to build a query which returns the range of consecutive values that exist in the collection? (i.e. 0 to 234 and 653 to 667 and 10543 to 22000) </p>
  
  <p>With this information, I would instantly know to fill missing documents between 235 to 652 and 668 to 10542 and continue at 22001...</p>