I'm making a chat app and I want to store only the latest 50 messages. I want to delete the 50th item when a new message arrives. How can I do that?
Checking the count of messages and deleting by calling a method each time from my app looks kinda inefficient. Is there any way to do it automatically? Any type of rules or something?
My app is written in C# using Xamarin.Forms. I'm using FirebaseDatabase.net library.
There is no configuration for this. You will have to somehow maintain a count, check the count on each new child, and delete the oldest child if the count exceeds your threshold. If you don't want to write this code, you could look into using the RTDB Limit Child Nodes extension which contains some code that might do what you want.