title: How to create a (double) linked list structure in MongoDB?
body: <p>I'm trying to store a multitude of documents which are double linked i.e. they can have a predecessor and a successor. Since the collection exists of different documents I'm not sure if I can create a feasible index on it:</p>
  
  <pre><code>{"_id": "1234", "title": "Document1", "content":"...", "next": "1236"}
  {"_id": "1235", "title": "Document2", "content":"...", "next": "1238"}
  {"_id": "1236", "title": "Document1a", "content":"...", "prev": "1234"}
  {"_id": "1237", "title": "Document2a", "content":"...", "prev": "1235", "next": "1238"}
  {"_id": "1238", "title": "Document2b", "content":"...", "prev": "1237", "next": "1239"}
  ...
  </code></pre>
  
  <p>Since I'll need the whole 'history' of a document including prev and next documents I guess I'll have to perform a multitude of querys depending on the size of the list? </p>
  
  <p>Any suggestions on how to create a performant index? A different structure for storing double linked lists would also be interesting.</p>