title: Cloud Functions - Remove Firestore documents after variable time and notify user
body: <p>I have seen a similar question with deleting Firebase Realtime Database data after a certain time, based on a write trigger here<br/></p>
  
  <p><a href="https://stackoverflow.com/questions/32004582/delete-firebase-data-older-than-2-hours">Delete firebase data older than 2 hours</a></p>
  
  <p><em>How can I achieve this in Firebase Firestore?</em><br/></p>
  
  <hr>
  
  <p><strong>Info:</strong><br/></p>
  
  <p>My Firestore layout is:<br/>
  <em>Main Collection<br/>
  --Doc 1<br/>
  ------Sub Collection<br/>
  ----------Doc xyz1<br/>
  ----------Doc xyz2<br/>
  --Doc 2<br/>
  ------Sub Collection<br/>
  ----------Doc abc1<br/>
  ----------Doc tyu1<br/>
  ----------Doc tyu2<br/></em></p>
  
  <p>Each user may have multiple Sub Docs (xyz1, xyz2), and they could change which Main Doc it's loaded into. Both collections are known and won't change, but the main doc and sub docs are variable. The function should wait a variable amount of time (10-120 minutes) before removing specific Sub Docs. When complete, the user/owner of the deleted Sub Docs needs a notification.<br/> <br/>
  <strong>Edit:</strong> Best I can find is there are no Time To Live (TTL) documents for Firestore which I would be able to make work, and periodic checking/cleaning that is advised just doesn't work for my specific use case.<br/></p>
  
  <p><strong>Edit 2 -Further Detail-:</strong> Each user will privately hold their unique doc/s (abc1). At their discretion, they will pick a Main doc (Doc 2 in the above), and commit their doc to its sub-collection. <br/>
  At this current point in time, when the users private doc is successfully submitted to the public sub-collection, an aysnc task has a countdown timer, on completion of which, will then remove the users aforementioned document. This works great, but when the user leaves the app or doesn't have internet connection when the timer is up, the docs aren't deleted. <br/><br/>
  This leads me to the original question, thinking I could utilise Cloud Functions to perform the removal actions after the timer count-down.</p>