You have two options:
-
You add a timestamp along with your data so that you can use an app or a function in your app to clean your database by retrieving all values and loop through to check if any of the entries need to be deleted.
-
Use Firebase functions to check the internal Firebase data and remove old entries.
Firebase keeps internal logs which has the timestamp of the created record time but you can only get these internal values through the Firebase Functions.