title: Auto deletion of documents from mongodb after specified time
body: <p>I want to auto delete documents from a <code>collection</code> in mongodb based on a <code>ttl</code>. I have gone through other answers and figured out the following way:</p>
  
  <pre><code>db.collection.createIndex( { "createdAt": 1 }, { expireAfterSeconds: 3600 } )
  </code></pre>
  
  <p>This will delete the documents after <code>expireAfterSeconds</code> interval from <code>createdAt</code> field. </p>
  
  <p>However, the problem with above is that it is not document specific. In the above scenario, all documents will be deleted after <code>3600</code> time from creation. However, in my case, each document in the collection needs to be deleted at different time intervals. So, each document need to have its own <code>ttl</code>. How can I achieve this?</p>