title: Implementing pagination in mongodb
body: <p>I know that it is a bad practice to use <code>skip</code> in order to implement pagination, because when your data gets large <code>skip</code> starts to consume a lot of memory. One way to overcome this trouble is to use natural order by <code>_id</code> field:</p>
  
  <pre><code>//Page 1
  db.users.find().limit(pageSize);
  //Find the id of the last document in this page
  last_id = ...
  
  //Page 2
  users = db.users.find({'_id'&gt; last_id}). limit(10);
  </code></pre>
  
  <p>The problem is - I'm new to mongo and do not know what is the best way to get this very <code>last_id</code></p>