title: How to query a directory tree without loading them in memory
body: <p>I have a root directory, for example <strong>events</strong>.</p>
  
  <p>Every event is a directory containing files, and there are millions of events.</p>
  
  <p>Directories in the <strong>events</strong> directory:</p>
  
  <pre><code>...
  2018-01-17-18:40:51.151343-1bb809
  2018-01-17-20:55:22.627688-26ada5
  2018-01-17-20:55:27.919532-8243cd
  2018-01-17-20:56:30.743072-94e913
  2018-01-17-20:57:39.824845-64ccb7
  ...
  </code></pre>
  
  <p>What I am trying to do is:</p>
  
  <ul>
  <li><p>Load the directories one by one, instead of doing it in one call e.g. <strong>fs.readDir</strong></p></li>
  <li><p>As the directory names are timestamped, I want to be able to query them with </p></li>
  </ul>
  
  <p>e.g.</p>
  
  <pre><code>{ time: 
      $gte: t1
      $lte: t2
  }
  </code></pre>
  
  <p>How would I do this query, with performance, without reading all the directories in memory at once?</p>
  
  <p>I am using NodeJs 9</p>