Is There A Way To Limit The Number Of Children In Firebase?
I have a firebase into which i'm pushing quite regularly, much like a chat, and i'm concerned about the number of children gathering in the firebase. They are all removed when all
Solution 1:
You could implement something like this using a ring buffer. If you wanted to have no more than 50 nodes, you could have children of a node referenced as /0, /1, /2, ... /49, and write to those as data is being generated. Using a transaction()
you could then have another location in Firebase keep track if current 'start' and 'end'. Priorities could also be used in conjunction with this approach to keep this ordered (for example, by timestamp.) This approach would also have the benefit of not having to prune the data as it grew.
We don't currently have a mechanism to enforce this using server-side security rules, but I've made a note of it in our internal tracker.
Post a Comment for "Is There A Way To Limit The Number Of Children In Firebase?"