Hi Koders!
I know this is not a Kodular issue, but maybe any user in the community can help me.
In Firebase Realtime Database, how can you do so that a bucket is automatically deleted some time after it is created, for example, a week?
I have the intuition that it can be done through Functions in Google Cloud, but I’m lost there.
Some help will be welcome!
Why do you need to delete the project bucket? You can delete / change values instead. What is the use case?
My app is for creating and practice yoga sessions. Users can share this sessions. Now I do it with the phone number of each user, but I want to do it with a code, so anyone who has this code can download the session. The bucket will be the code created, where the session is saved.
But this codes have to expire eventually, and this shouldn’t be dependant on the user who generated it, so the best way is that the codes are deleted automatically after some period of time.
I feel you should learn more about the Firebase database, before you try to implement it in your app.
Firebase stores data in a nested form. So, you can nest one user’s data all together. There is no need to delete anything (especially, you should not delete the primary project bucket! It’s the entry point to the whole database*). Just change the values as required.
*Once you delete the primary project bucket, it will delete the whole Database, denying access for all other users into it.
I have Firebase implemented, creating a bucket for the shared sessions of each user, using his phone number as buckets, and this buckets are deleted when the user wants to delete their number in the app.
I think the same can be done with codes, but the problem is that this codes do not depend on the user who created them, so have to be deleted automatically.
Of course I have to learn more about Firebase, just was asking for a kind of guide to start with this matter.
Thanks anyway.
You cannot delete the project bucket but once all the tags under the bucket are cleared then it may possible
I said bucket but I mean tags, yes. I want to delete a tag after a period of time (always the same) after it was created.
Then once tag is created by the user save or put the end time in tinydb or same dB. Next time when user open the app then get the end time and compare with current time . If the value is positive leave it if it is negative (it mean current time is greater than saved time) then clear the tag
But the tags should be deleted even if the user doesn’t open the app. It should be deleted automatically by Firebase, but I don’t know how to do it.
I think it can be done with a Cloud Function, but I don’t know how to program it.
Store the timestamp in FB is easy, but delete the tags according to this timestamp is the problem for me.
Then I don’t know how for it is possible… you can try two options
-
Use admin app. Once open it do the above said things and del the tag with expired time
-
Use background task extension created by @Xoma
(Update: I Think second one is discontinued)
Yes you can do this but its not automaticly but may b helpful
Today date and After date extension
when screen intialize {
when Today date is largen than After date then do {
Delete this bucket
}
}