I currently have a Google App Engine python script that reads a firestore. The structure is as follows
<collection name=Location1>
<document name=timestamp1>
data-array
<document name=timestamp2>
data-array
<document name=timestamp3>
data-array
<collection name=Location2>
<document name=timestamp1>
data-array
<document name=timestamp2>
data-array
<document name=timestamp3>
data-array
This is basically a cache. This works best for my appengine as it dynamically generates a webpage so it needs to be fast. It takes location as an input and tries to pull the past 12hrs worth of data from the "cache". If it does not exist, it pulls the missing data from web and writes it into the cache. The issue is that I am not deleting old data and there is no guarantee the location (collection) will ever get called again. I could restructure my data to have timestamp collections with location documents but that makes looking up data difficult.
Therefore, I would like a separate program (cloud function?) to periodically scan my firestore and delete anything more than X hours from each collection or delete the entire collection if all the documents are older/deleted. I realize I probably need to add a timestamp entry to each document so I can query on it.
All I have been able to find regarding how to accomplish this is at https://firebase.google.com/docs/firestore/solutions/delete-collections however, I have having trouble understanding it and it seems to require me to specify the collection.