I have a realtime database with following structure:
"keys" :
"randomUserId1" :
"randomKey1" : timestamp1
"randomUserId2" :
"randomKey2" : timestamp2
"randomKey3" : timestamp3
"randomUserId3" :
"randomKey4" : timestamp4
The timestamp values are createdtime in milliseconds. I now want to delete all keys where timestamp is too old, using Firebase function and javascript. Timing is not that important, so the delete function may trigger on a suitable write somewhere else in the database.
I have tried modifying the example method delete old child nodes, but cannot understand how to make it work with above database structure.
How could I write a js function to accomplish above?
I could of course add a key/value pair ("timestamp" : timestamp) below "randomKey", if that makes things easier.