Is there a way to limit the number of children in firebase?

I have a firebase in which I click pretty regularly, like a chat, and I am worried about the number of children going to firebase. All of them were deleted when all the connections disappeared, but is there a way to limit their number?

Hooray!

+4
source share
1 answer

You can implement something like this using a ring buffer . If you want to have no more than 50 nodes, you can have node children that are referenced as /0,/1,/2,.../49 and write them when creating data. Using transaction() , you can have another place in Firebase to track the current start and end. Priorities can also be used in conjunction with this approach to keep it orderly (e.g. by timestamp). This approach would also have the advantage that it should not reduce data as it grows.

We currently do not have a mechanism to ensure this using server-side security rules, but I did this in our internal tracker.

+3
source

All Articles