title: What's the best way to segment a data by dates
body: <p>As the title says</p>
  <p>consider dummy data like this (some users in my mongoose database)</p>
  <pre><code>[{ name : &quot;ahmed&quot; , registeredIn : 1590739626724 },
  { name : &quot;ahmed&quot; , registeredIn : 1590739626724 }
  { name : &quot;ahmed&quot; , registeredIn : 1590739626724 }
  { name : &quot;ahmed&quot; , registeredIn : 1590739626724 }
  { name : &quot;ahmed&quot; , registeredIn : 1590739626724 }]
  </code></pre>
  <p>in my admin panel , I'd like to return a chart which display number of registered users per each month</p>
  <p>just need numbers , 2 in May , 3 in June and so on..</p>
  <p>what's the quickest solutions ?</p>
  <p>the only solution in my mind now is a bit bad</p>
  <p>to fetch each month separately</p>
  <blockquote>
  <p>fetch users between timestamp X &amp; Y</p>
  <p>fetch users between timestamp X &amp; Y</p>
  <p>fetch users between timestamp X &amp; Y</p>
  <p>fetch users between timestamp X &amp; Y</p>
  </blockquote>
  <p>what if I want to fetch about 20 months , will I call the MongoDB 20 times ?</p>
  <p>is there any more better solution ?</p>